
Option in Rust and How to Stop Fearing the Null Case
Option replaces null in Rust. Learn Some and None, map, and_then, unwrap_or, the question mark operator and why unwrap on None panics.
Tag
31 posts

Option replaces null in Rust. Learn Some and None, map, and_then, unwrap_or, the question mark operator and why unwrap on None panics.

Rust enums carry data in each variant, which replaces the class hierarchy and the nullable field. See the syntax, match, methods, and where it beats inheritance.

Rust match is exhaustive: the compiler checks every case. Learn literals, ranges, guards, bindings, tuple, struct and slice patterns with working examples.

Integer overflow panics in a debug build and wraps in a release build. See the exact behavior, the checked, wrapping and saturating methods, and the setting that changes it.

A tour of Rust primitive and compound types: integers, floats, bool, char, tuples, arrays and slices, with their sizes, defaults and the casts that bite.

Rust variables are immutable by default. Learn let, let mut, shadowing, constants and the compiler messages you will meet when you change a value you did not mark.

A fast route through the Rust language for developers who already code in another language, built around one small program that touches ownership, enums, traits and errors.