Why the need for Empty / Elem in a primitive data structure?

I have a simple list:
pub enum List {
Empty
 Elem(i32, Box<List>),
}

Why should I write here Empty if compiled without?
What is Elem? It is some sort of data structure? I don't advertise it further and found it mentioned in the documentation, but it works.
March 23rd 20 at 19:26
1 answer
March 23rd 20 at 19:28
Solution
> Why should I write here Empty if compiled without?

The giving without Elem compiled, but to construct a real list without a trailing empty node will not work, because it would have to be infinite.

> What is Elem?

This is one of the options you declare the enumeration List, which contains two unnamed fields clear what types.

> I didn't advertise it further and found it mentioned in the documentation, but it works.

It's just a simple syntax enumerations (enum's) that in any textbook on grow is described, for example in Rastoke: https://doc.rust-lang.org/book/ch06-01-defining-an...

Find more questions by tags Rust