In Chapter 2, Sequential Rust Performance and Testing, we very briefly dipped into the implementation of std::collections::HashMap. Let's continue with that approach of dissecting the standard library, paying special attention to the concerns of memory that pop up.
Implementations
Option
Let's examine Option<T>. We've already discussed Option<T> in this chapter; that it's subject to null pointer optimization on account of its empty None variant in particular. Option is as simple as you might imagine, being defined in src/libcore/option.rs:
#[derive(Clone, Copy, PartialEq, PartialOrd, Eq, Ord, Debug, Hash)] #[stable(feature = "rust1", since = "1.0.0")] pub enum...