Traits
Checkpoints
- `Clone` and `Copy` Essential Two traits that classify how a value can be duplicated. `Clone` says 'a copy can be made, possibly at non-trivial cost' via an explicit `.clone()` call. `Copy` is the stricter promise 'duplicating this value is a trivial bitwise copy', which lets the compiler duplicate values implicitly. You'll see which built-in types implement each, why `Copy` requires `Clone`, and why `String` is `Clone` but not `Copy`.
- The `Drop` Trait Essential `Drop` lets a type run custom cleanup code the instant a value of that type goes out of scope. You'll see why `Drop` is what makes `Box`, `Vec`, and `String` automatically release their heap memory, how the compiler guarantees `drop` runs exactly once, and why you almost never call `drop` directly — the compiler inserts the call for you at the end of each scope.
- The `Sized` Trait and `?Sized` Essential `Sized` is the marker trait every type with a compile-time-known size automatically implements — the precondition for a value to live on the stack or be passed by value. You'll see why every generic type parameter has an implicit `T: Sized` bound, when to relax it with `T: ?Sized`, and which Rust types are *not* `Sized` (slices `[T]`, `str`, trait objects `dyn Trait`).