the example in str::find
assert_eq!(s.find(|c: char| (c < 'o') && (c > 'a')), Some(4));
could be much simpler
assert_eq!(s.find('b'..'o'), Some(4));
the example in str::find
assert_eq!(s.find(|c: char| (c < 'o') && (c > 'a')), Some(4));
could be much simpler
assert_eq!(s.find('b'..'o'), Some(4));
If it's only about using ranges, you can do:
assert_eq!(s.find(|c| ('b'..'o').contains(&c)), Some(4));
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.