Rust provides a handy attribute that allows you to access a number of commonly used traits without having to implement them yourself time and again. They are called using #[derive(Trait_Name)].
The traits available are as follows:
- Clone: This creates a clone of the object
- Copy: This creates a copy of the object
- Debug: This provides debugging code
- Default: This gives a useful default value for a type
- Eq: Equality, this is similar to PartialEq except for all parameters within a struct
- Hash: This is a hashable type
- Ord: Order, these are the types that form a total order on all types
- PartialEq: Partial Equality, this only tests on a subset of the struct
- PartialOrd: Partial Order, values that can compared to create a sort order