Skip to content

Glossary: Data Structures and Algorithms in Rust

derive

Also written: #[derive(...)], #[derive(Hash, PartialEq, Eq)], #[derive(PartialEq, Eq, PartialOrd, Ord)]

An attribute that asks the compiler to write trait code for a struct. Deriving Hash, PartialEq and Eq makes a struct usable as a key. Deriving the ordering traits compares fields in the order written, which is why Delivery lists deadline first.

Where the book teaches it

Related terms

HashableTraitOrdering