When you define a new trait, you’ll usually want to provide blanket implementations for that trait for:

  • &T, no dereferencing with shared references
  • &mut T, same as above
  • Box<T>, for heap-allocated types

For ergonomics, also consider:

  • IntoIterator for both &T and &mut T to have for loops
  • Deref if you provide a transparent type (like Arc) allows calling methods on the inner type via .. Avoid it on types in which you don’t know in advance the inner type

See also

References

  • J. Gjengset, Rust for Rustaceans: Idiomatic Programming for Experienced Developers. No Starch Press, 2021.