For key equality lookup, we can use a data type like a hashmap, but is there a data structure for looking up values matching arbitrary ranges?
The Rust code below emulates this using a match
expression but I'm looking to not have to hard code the cases in code.
let x = 5;
match x {
d if d <= 0 => println!("d <= 0"),
d if 1 < d && d <= 3 => println!("1 < d <= 3"),
d if 4 < d && d <= 6 => println!("4 < d <= 6"),
_ => {}
}