Version: 1.1.0

Traits cheat sheet

The standard traits you will see in signatures.

Essentials

  • Movable allows a value to be transferred.
  • Copyable allows an implicit or explicit duplicate.
  • Equatable requires __eq__.
  • Stringable and Writable feed print.
  • KeyElement is what Dict requires of keys.

Example

fn only_eq[T: Equatable](a: T, b: T) -> Bool:
    return a == b

Keep in mind

Conform to the smallest trait that expresses the operation. Extra bounds make callers unhappy.