Back to articles
[Rust Guide] 6.2. The Option Enum

[Rust Guide] 6.2. The Option Enum

via Dev.toSomeB1oody

6.2.1. What Is the Option Enum? It is defined in the standard library and included in the prelude (the pre-imported module). It is used to describe a scenario where: a value may exist, and if so, what data type it has; or it may simply not exist. 6.2.2. Rust Has No Null In most other languages, there is a Null value, which represents no value . In those languages, a variable can be in two states: Null ( Null ) Non-null Null ’s inventor, Tony Hoare, said in his 2009 talk “Null References: The Billion Dollar Mistake”: I call it my billion-dollar mistake. At that time, I was designing the first comprehensive type system for references in an object-oriented language. My goal was to ensure that all use of references should be absolutely safe, with checking performed automatically by the compiler. But I couldn’t resist the temptation to put in a null reference, simply because it was so easy to implement. This has led to innumerable errors, vulnerabilities, and system crashes, which have prob

Continue reading on Dev.to

Opens in a new tab

Read Full Article
5 views

Related Articles