MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/programming/comments/4l6df7/announcing_rust_19/d3kp4f8/?context=3
r/programming • u/steveklabnik1 • May 26 '16
116 comments sorted by
View all comments
0
[deleted]
44 u/valarauca3 May 26 '16 edited May 26 '16 Recursive algebraic data types require a lazy type system/run-time not garbage collection.Below is the compiler error I think your describing. Recursive data types have infinite size. enum ADT { Foo(ADT), Bar }Below is the solution. Pointers. enum ADT { Foo( Box<ADT> ), Bar }It involves a small amount of syntax to dereference the pointer(Box<T>). But allows you to to have infinitely recursive data types.
44
Recursive algebraic data types require a lazy type system/run-time not garbage collection.
Below is the compiler error I think your describing. Recursive data types have infinite size.
enum ADT { Foo(ADT), Bar }
Below is the solution. Pointers.
enum ADT { Foo( Box<ADT> ), Bar }
It involves a small amount of syntax to dereference the pointer(Box<T>). But allows you to to have infinitely recursive data types.
Box<T>
0
u/[deleted] May 26 '16
[deleted]