Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Update
unnecessary_lazy_evaluations
to allow closures for trivial functions according to the developer's preference.The current list of trivial functions is
is_empty
,len
, andas_*
. This list cannot be updated without causing churn, because e.g., calls tounwrap_or_else
andunwrap_or
would need to be swapped for each addition and removal. This list is also undocumented and not based on actual method complexity, but repositories need to follow it to be compliant with this default lint. Leaving these trivial functions up to developer preference allows developers to not need to think about which functions Clippy considers lazy.A configuration could be added later to re-enable this without any backward-compatibility concern, but it should not be enforced by default.
changelog: [
unnecessary_lazy_evaluations
]: allow optional closure for trivial functionsFixes: #8109