Trait

Noun · Development

Definitions

  1. A language construct that defines shared behavior as a set of method signatures (and optionally default implementations) that types can implement. Used in Rust, Scala, PHP, and others as an alternative to class inheritance.

    In plain English: A way to say 'any type that has these methods' — like an interface that can also include default behavior, used instead of inheritance.

    Example: "Implement the Display trait for your struct so it can be printed with println!."

Related Terms