armanriazi•rust•error•[E0072]: recursive type `List` has infinite size --> src/main.rs:3:1 | 3 | enum List { | ^^^^^^^^^ recursive type has infinite size
//resolved:Definition of List that uses Box<T> in order to have a known size
enum List {
Cons(i32, Box<List>),
Nil,
}
use crate::List::{Cons, Nil};
fn main() {
let list = Cons(1, Box::new(Cons(2, Box::new(Cons(3, Box::new(Nil))))));
}