Conceptual
Login

Implementing a Trait for Your Own Type

Implementing a trait means writing the block of code where your own type keeps the promises that trait makes. You fill in each required function, and from then on anything that accepts the trait accepts your type. It is the standard way to plug your code into a framework someone else wrote.

Questions this Concept answers

  • Why must a trait's methods live in an `impl ... for ...` block rather than among the type's ordinary inherent methods?