Module 6Traits & GenericsLesson 6 of 816 min
Common std Traits
Debug, Clone, Default, PartialEq on domain types.
Daily derives
rust
#[derive(Debug, Clone, Copy, PartialEq)]
struct TickSize { cents: i64 }Note on f64
f64 is PartialEq but not Eq (NaN).
Challenge
Discuss why Eq is not derived for Quote with f64 fields.
Tips
- NaN breaks Eq
- Clone is explicit
- Debug for logging
Try it live
Common std TraitsRust 2021
Loading editor…
Output
Press Run to compile and execute.