NonZero* types

`NonZeroU8`, `NonZeroI32`, etc. are integer types statically guaranteed to be non-zero. They cost the same as the underlying integer but enable the niche optimisation that lets `Option<NonZeroU32>` fit in 4 bytes (using zero to encode None). Use them for IDs, counts, and indexes that must never be zero.

Checked arithmetic

Plain `+ - * /` panic in debug builds and wrap in release builds on overflow. For predictable behaviour, use the explicit family: `checked_add` returns `Option<T>` (None on overflow), `wrapping_add` always wraps, `saturating_add` clamps at the type's max / min, `overflowing_add` returns `(T, bool)` for both the result and the overflow flag.

For deeper background, see a complete cheat-sheet of std collection complexities for the broader context behind this section.

ParseIntError and ParseFloatError

`str::parse::<i32>()` returns `Result<i32, ParseIntError>`. The error's `kind()` method classifies the failure: empty input, invalid digit, overflow, underflow. For strict parsing of integers in different bases, use `i32::from_str_radix`.

Float specifics

Floating-point arithmetic is in `std::f32` and `std::f64`, not `std::num`. NaN is its own world: `NaN != NaN`, NaN compares as neither less nor greater than anything. The `total_cmp` method gives you a total order if you need one. For IEEE-754-strict rounding modes or mixed-precision ops, look beyond std.

For deeper background, see the official Rust API guidelines for module-level design for the broader context behind this section.

Bit operations

Integer types expose `count_ones`, `count_zeros`, `leading_zeros`, `trailing_zeros`, `rotate_left`, `rotate_right`. They compile to single-instruction CPU intrinsics on every modern target. Use them for hash mixing, bitsets, and low-level encoding work.