extern crate enumify; enumify::enumify! { #[derive(Debug)] pub enum Term; #[derive(Debug)] pub struct Var(V); #[enumify(Box)] #[allow(dead_code)] #[derive(Debug)] pub struct App { function: Term, argument: Term, } #[enumify(Box)] #[derive(Debug)] pub struct Abs { #[allow(dead_code)] variable: V, #[allow(dead_code)] body: Term, } } impl From for Term { fn from(value: usize) -> Self { Self::from(Var(value)) } } #[test] fn it_works() { let _ = Term::from(App { function: Term::from(Abs { variable: 0, body: Term::from(0), }), argument: Term::from(1), }); }