I would like to create a Range and then check if the variable is contained in this range. Something like this:
fn main() { let a = 3..5; assert!(a.contains(4)); }
Now I see only the obvious thing: Iterator::any . This is ugly because it will require operation O (1) and make it O (n):
fn main() { let mut a = 3..5; assert!(a.any(|v: i32| v == 4)); }
source share