trait-concept
Rust Supertraits
A supertrait is a required capability of every implementing type. Methods can use that capability without adding another bound. Implementing the subtrait does not itself generate the supertrait implementation. Expected output (not executed): Box Why: Boxed meets both contracts, so the default method may call name. Common mistake: Assuming supertraits copy fields or automatically implement parent behavior.
Formal Syntax & Structure
rust syntaxrust
trait Printable: Named { /* items */ }Working Example
Example Snippetrust
trait Named { fn name(&self) -> &str; }trait Printable: Named { fn print(&self) { println!("{}", self.name()); }}struct Boxed;impl Named for Boxed { fn name(&self) -> &str { "Box" } }impl Printable for Boxed {}fn main() { Boxed.print(); }