In the compound data types section, I think it would be prudent to introduce
enum Option {
Some(i32),
None
}
as an example early on so as to remove some of the confusion around Option
later on. From some question in the IRC, it seems like people don't understand that Option
is just an enum
.
So if we introduce it here in a specialized version and mention that this example is used throughout Rust as the return type for operations which may fail (and put a note explaining that this is done with generics, which will be introduced later), it may lead to people understand Option
better.
Also, we may want to build on this example later by impl'ing unwrap()
on Option
and showing that it's really just a match underneath, which also confused people (there's a lot of "What is unwrap() and why is it everywhere?!?" going around).