10928 shaares
389 private links
389 private links
- Indexing into a vector: prefer better pattern matching or raw array with index safety instead
- Lazy use of
Default: initialize all fields instead - Avoid fragile trait implementations that pass silently on changes
Fromtraits must be infaillible, useTryFromif any error can occur. Make it explicit.- Avoid non-exchaustive matches (with
_ =>) - Use decriptive names for unused variables with the
_placeholder. - Avoid temporary mutability and make it explicit instead:
let mut data = ....; .... ; let data = data - Defensively handle constructors with
#[non_exhaustive], so creating an raw instance of a struct should be prohibited outside constructor functions. - Use
#[must_use]to avoid unused instance of the struct. - Avoid boolean parameters and in case of need, prefer enums.
- Use Clippy lints:
- clippy::indexing_slicing
- clippy::fallible_impl_from
- clippy::wildcard_enum_match_arm
- clippy::unneeded_field_pattern
- clippy::fn_params_execussive_bools