1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
TraitsA trait is a collection of methods. Data types can implement traits. To do so, the methods making up the trait are defined for the data type. For example, the In this way, traits are somewhat similar to Java interfaces and C++ abstract classes. Some additional common Rust traits include:
Because traits indicate shared behavior between data types, they are useful when writing generics. Further information |
