Why Rust chose to use an enum for the Option type instead of a trait?
In Rust, we have the Option type defined as:
pub enum Option<T> {
None,
Some(T),
}
Just wondering from a programming language implementation/theory standpoint (using Rust as inspiration), why this was defined as an enum and not something else, such as using traits.
pub struct None {}
pub struct Some<T> {
value: T
}
pub trait Option<T> {}
impl Option<T> for Some<T> {}
impl Option<T> for None {}
I don't know if something like this would really work, but something along these lines.
P.S. I don't have a deep practical understanding of Rust yet, just learning it's APIs and reading the docs to get a better understanding of type systems.