interval_map

Macro interval_map 

Source
macro_rules! interval_map {
    () => { ... };
    ([$ix:ty] $($range:expr => $value:expr),+ $(,)?) => { ... };
    ($($range:expr => $value:expr),+ $(,)?) => { ... };
}
Expand description

Creates an IntervalMap from a list of range-value pairs.

ยงExamples

use intervalmap::interval_map;

// Empty map
let empty: intervalmap::IntervalMap<u32, i32> = interval_map!{};
assert!(empty.is_empty());

// Map with intervals
let map = interval_map!{
    0..10 => "first",
    20..30 => "second",
};
assert_eq!(map.get(5), Some(&"first"));
assert_eq!(map.get(25), Some(&"second"));

// With explicit index type
let map = interval_map!{ [u8] 0..10 => "a", 20..30 => "b" };