Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR RUST

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))))));
}
 
PREVIOUS NEXT
Tagged: #recursive #type #infinite #size #enum #List #recursive #type #infinite #size
ADD COMMENT
Topic
Name
2+1 =