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 the "derivable" traits:
Eq
,
PartialEq
,
Ord
,
PartialOrd
Clone
,
to create T
from &T
via a copy.Hash
, to
compute a hash from &T
.Default
,
to create an empty instance of a data type.Zero
, to
create a zero instance of a numeric data type.Debug
, to
format a value using the {:?}
formatter.