Type Design
- Use newtypes to enforce domain invariants (e.g.,
struct Port(u16)over bareu16). - Derive
Debugon all types. DeriveClone,PartialEq,Eq,Hashwhen semantically correct. - Use
#[non_exhaustive]on public enums and structs that may grow. - Prefer
enumfor closed sets,traitfor open extension.