Naming Conventions for Traits

(Jin Qing’s Column, Jan., 2024)

From: https://github.com/rust-lang/api-guidelines/discussions/28

  • If the trait has a single self-explanatory method (or a set of nearly identical methods), name it after the method: Clone, Hash, Default, Into, Write, ToOwned, AsRef, Extend.
  • If the trait has no methods, name it after what ability (Send, Sync, Copy) or property (UnwindSafe) its implementors have.
  • If the trait has a broader set of methods or a single method that is not self-explanatory, the name should describe either what its implementors are (Iterator, Hasher, Fn, Error, Future, Termination) or what ability/property they have (AsciiExt, fmt::Debug, fmt::Binary).