Could you separate out the data structure, i.e. keep your BTreeMap<u32, u32> for intervals, but add a Vec<u32> for available slots. Update both on insert/remove, then for range queries use the Vec<u32>?
Sorry if this is dumb I'm a> not a rustian and b> not really a computer scientist lol