mirror of
https://github.com/n0-computer/noq.git
synced 2026-09-25 04:35:17 +00:00
Fix insert and remove behavior for empty ranges
`RangeSet::insert` and `RangeSet::remove` returned `true` when trying to insert an empty range.
This commit is contained in:
committed by
Dirkjan Ochtman
parent
01b95116e9
commit
e6f28e9d29
@@ -56,7 +56,7 @@ impl RangeSet {
|
||||
}
|
||||
|
||||
pub fn insert(&mut self, mut x: Range<u64>) -> bool {
|
||||
if x.end == 0 || x.start == x.end {
|
||||
if x.is_empty() {
|
||||
return false;
|
||||
}
|
||||
if let Some((start, end)) = self.pred(x.start) {
|
||||
@@ -99,6 +99,10 @@ impl RangeSet {
|
||||
}
|
||||
|
||||
pub fn remove(&mut self, x: Range<u64>) -> bool {
|
||||
if x.is_empty() {
|
||||
return false;
|
||||
}
|
||||
|
||||
let before = match self.pred(x.start) {
|
||||
Some((start, end)) if end > x.start => {
|
||||
self.0.remove(&start);
|
||||
|
||||
Reference in New Issue
Block a user