The Sized trait guarantees that a type has a known size at compile time, which is required for most generic code to work. By default, Rust assumes generic type parameters implement Sized, but you can opt out of this requirement using the ?Sized bound to accept unsized types like slices or trait objects.
// Default: T must have a known size
fn generic_sized<T>(t: T) {
// ...
}
// Opt-out: T can be unsized (must be used behind a pointer)
fn generic_maybe_sized<T: ?Sized>(t: &T) {
// ...
}