3 ms·
> Rust lacks a "nil" Rust has the concept of a possibly-null pointer; you just have to write it explicitly by wrapping something in the Option type. In partic
by JoshTriplett 12y ago
> Rust lacks a "nil"
Rust has the concept of a possibly-null pointer; you just have to write it explicitly by wrapping something in the Option type. In particular, Rust has a guaranteed optimization that says if you have a type with a single zero-argument constructor and a one-argument constructor, and the one-argument constructor takes a type that can't be null, then the type with those two constructors will just use null to represent the zero-argument constructor. So Option on a pointer/reference type just represents a nullable pointer.
- Animats 12y agoRust's "Option" type is a generic enum. There is no explicit "nil".
- kachnuv_ocasek 12y agoThat's what she said.