Traits and Generics

Traits Are Interface Types

  • Define methods, fields and types that must be present in the implementation of a struct or enum

  • Principal mechanism for code reuse in Rust

  • Interact strongly with and enhance "generic" types (parametric polymorphism)

Defining A Trait

Trait Bounds vs Trait Objects

Misc Trait Things

  • Traits and scope control

  • Subtraits

Last modified: Tuesday, 1 May 2018, 5:02 PM