Arithmetic operator traits

`Add`, `Sub`, `Mul`, `Div`, `Rem`, `Neg` map to `+`, `-`, `*`, `/`, `%`, unary `-`. Implement them for your own numeric or vector types. The associated `Output` type lets `+` between two `Vector2` produce a `Vector2`, while `Vector2 * f32` could produce a `Vector2`. The `*Assign` family (`AddAssign`, etc.) maps to compound assignment (`+=`).

Index and IndexMut

Implement `Index<T>` to enable `obj[idx]` syntax, returning a reference. `IndexMut` enables `obj[idx] = value`. Common in container types — Vec, slice, HashMap all implement Index.

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

Deref and DerefMut

`Deref` overloads `*x` and enables deref coercion: `&String` automatically converts to `&str` because `String: Deref<Target = str>`. Smart pointers (`Box`, `Rc`, `Arc`) all implement Deref so `*box_value` accesses the wrapped value. Don't implement Deref for non-pointer-like types — it confuses readers.

Range types

`Range<Idx>`, `RangeFrom`, `RangeTo`, `RangeFull`, `RangeInclusive`, `RangeToInclusive` — one per syntactic form (`a..b`, `a..`, `..b`, `..`, `a..=b`, `..=b`). They all implement Iterator (over integers) and SliceIndex (for slicing). The `RangeBounds` trait abstracts over all six for APIs like `BTreeMap::range`.

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

Other useful operator traits

`Drop` runs custom code when a value goes out of scope — for releasing OS handles, decrementing reference counts, or logging. `Fn`, `FnMut`, `FnOnce` are how closures are typed; you usually take `impl Fn(...)` rather than implementing them by hand.