Derive
The compiler is capable of providing basic implementations for some traits via
the #[derive] attribute. These traits can still be
manually implemented if a more complex behavior is required.
The following is a list of derivable traits:
- Comparison traits:
Eq,PartialEq,Ord,PartialOrd. Clone, to createTfrom&Tvia a copy.Copy, to give a type 'copy semantics' instead of 'move semantics'.Hash, to compute a hash from&T.Default, to create an empty instance of a data type.Debug, to format a value using the{:?}formatter.