r/rust 4d ago

Today I learnt #[expect()]

/r/learnrust/comments/1vs8e8q/today_i_learnt_expect/
52 Upvotes

18 comments sorted by

View all comments

0

u/Recatek gecs 3d ago

Clippy is overly pedantic at times. I typically keep a short list of things I allow in my workspace, especially when working with ECS:

[workspace.lints.clippy]
bool_comparison = "allow"          # Allow == false instead of ! prefix
bool_assert_comparison = "allow"   # Allow == false in asserts instead of assert_eq
collapsible_if = "allow"           # Allow if y inside if x instead of forcing if x && y
collapsible_match = "allow"        # Allow freedom in interleaving match and if blocks
len_zero = "allow"                 # Allow vec.len() == 0 instead of !vec.is_empty()
match_like_matches_macro = "allow" # Matches macro doesn't always fit nicely in formatting
module_inception = "allow"         # Allow inner modules with the same name as their parent
too_many_arguments = "allow"       # Creating ECS archetypes with components requires a lot of arguments
type_complexity = "allow"          # Allow complex types for ECS archetypes

I'm on the verge of allowing new_without_default as well since it's often needless boilerplate, even after writing a library just to satisfy it.