Suggest faster .contains()
instead of .iter().any()
for [u8]
and [i8]
slices
#13353
Labels
A-lint
Area: New lints
What it does
Suggest to replace
values.iter().any(|&x| x == 10)
withvalues.contains(&10)
as shown in the example for x beingu8
or ani8
. Contains uses specialization, thus gains 8-10x in performance.The generated assembly is significantly different too (see here).
Advantage
Drawbacks
Example
Could be written as:
The text was updated successfully, but these errors were encountered: