You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/// Gets an iterator over all the maximally-sized ranges/// contained in `outer_range` that are not covered by/// any range stored in the map.
This indicates that gaps will find holes in the range-map that intersect outer_range... We had an engineer check if a range was completely covered by the RangeMap by if range_map.gaps(&check_range).next().is_none() {...}, which seems like it should work (based on the documentation), but broke in our case, because the gaps iterator can return empty ranges:
#[test]fnadjacent_no_coalesce(){letmut range_map:RangeMap<u32,bool> = RangeMap::new();
range_map.insert(2..5,false);
range_map.insert(5..8,true);let outer_range = 2..8;letmut gaps = range_map.gaps(&outer_range);// Should yield an empty range.let gap = gaps.next();assert_eq!(gap,Some(5..5));assert_eq!(gap.unwrap().is_empty(),true);}
I think the current behavior is good, but the documentation could be improved to better indicate that gaps can return empty ranges.
The text was updated successfully, but these errors were encountered:
Thanks for reporting this, @acully-vmware. This looks like a bug to me, not just ambiguous documentation. In your example 5is covered by the map, so I don't think that it's valid to consider 5..5 to be a gap.
Sure, but 5 isn't in 5..5, either. It can be useful to know that there's a boundary between two elements of the RangeMap at 5, though I agree it doesn't sound like a "gap"... I can go either way, on this one.
I agree that finding the all the boundaries between ranges could be useful, but I'd rather introduce a separate iterator for that. The current behavior in the gaps iterator was an oversight, and I think most people would expect it to behave as your colleague did.
The documentation says:
This indicates that
gaps
will find holes in the range-map that intersectouter_range
... We had an engineer check if a range was completely covered by theRangeMap
byif range_map.gaps(&check_range).next().is_none() {...}
, which seems like it should work (based on the documentation), but broke in our case, because thegaps
iterator can return empty ranges:I think the current behavior is good, but the documentation could be improved to better indicate that
gaps
can return empty ranges.The text was updated successfully, but these errors were encountered: