You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Suggest to replace values.iter().any(|&x| x == 10) with values.contains(&10) as shown in the example for x being u8 or an i8. Contains uses specialization, thus gains 8-10x in performance.
The generated assembly is significantly different too (see here).
Advantage
8x faster code
Drawbacks
none(?)
Example
#[inline(never)]pubfnhas_any(values:&[u8]) -> bool{
values.iter().any(|&x| x == 10)}