Curriculum Traits & generics Derive and common traits exercise 1 · mcq
Derive and common traits
A struct Point should be printable via the {:?} debug
format without writing the Debug impl by hand. Pick the
attribute that asks the compiler to generate it.
TypeScript reference
About this theme
Rust leans on a small set of common traits: Debug, Clone, Copy, Default, PartialEq, Eq, PartialOrd, Ord, and Hash. Derive is the idiomatic way to ask the compiler for boring implementations. Planned exercises: 1. choose #[derive(Debug)]. 2. recognise derived equality. 3. choose Clone vs Copy. 4. fill a derive list. 5. fill a Debug print. 6. write a comparable struct. 7. write a default value. 8. translate TS equality assumptions. 9. fix a HashMap key type that lacks the required traits.