Rust theorytheory 0/50 · 0%
Abstraction · medium

22. Traits

Shared behaviour contracts.

Traits declare method signatures and optional defaults; `impl Trait for Type` provides them. The orphan rule requires either the trait or the type to be local. Traits underpin operator overloading, conversion and iteration.

Check your understanding

  1. 1. The orphan rule requires…

  2. 2. Can traits provide default methods?