![[Rust Guide] 6.2. The Option Enum](/_next/image?url=https%3A%2F%2Fmedia2.dev.to%2Fdynamic%2Fimage%2Fwidth%3D1200%2Cheight%3D627%2Cfit%3Dcover%2Cgravity%3Dauto%2Cformat%3Dauto%2Fhttps%253A%252F%252Fdev-to-uploads.s3.amazonaws.com%252Fuploads%252Farticles%252Fs01c0iu87b00e91hcdvu.png&w=1200&q=75)
[Rust Guide] 6.2. The Option Enum
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



