Skip to content

Commit

Permalink
Remove contains_item from Range*Ext
Browse files Browse the repository at this point in the history
`contains` was stabilized in Rust 1.35:
rust-lang/rust#59152
  • Loading branch information
jeffparsons committed Jul 12, 2020
1 parent bfcf48c commit b0e583d
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 26 deletions.
5 changes: 1 addition & 4 deletions src/inclusive_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,7 @@ where
.filter(|(range_start_wrapper, _value)| {
// Does the only candidate range contain
// the requested key?
//
// TODO: Use `contains` once https://github.com/rust-lang/rust/issues/32311
// is stabilized.
range_start_wrapper.range.contains_item(key)
range_start_wrapper.range.contains(key)
})
.map(|(range_start_wrapper, value)| (&range_start_wrapper.range, value))
}
Expand Down
5 changes: 1 addition & 4 deletions src/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,7 @@ where
.filter(|(range_start_wrapper, _value)| {
// Does the only candidate range contain
// the requested key?
//
// TODO: Use `contains` once https://github.com/rust-lang/rust/issues/32311
// is stabilized.
range_start_wrapper.range.contains_item(key)
range_start_wrapper.range.contains(key)
})
.map(|(range_start_wrapper, value)| (&range_start_wrapper.range, value))
}
Expand Down
18 changes: 0 additions & 18 deletions src/std_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ use std::ops::{Range, RangeInclusive};
pub trait RangeExt<T> {
fn overlaps(&self, other: &Self) -> bool;
fn touches(&self, other: &Self) -> bool;
// TODO: Remove once https://github.com/rust-lang/rust/issues/32311
// is stabilized.
fn contains_item(&self, item: &T) -> bool;
}

impl<T> RangeExt<T> for Range<T>
Expand All @@ -26,22 +23,13 @@ where
// or immediately adjacent.
max(&self.start, &other.start) <= min(&self.end, &other.end)
}

// TODO: Remove once https://github.com/rust-lang/rust/issues/32311
// is stabilized.
fn contains_item(&self, item: &T) -> bool {
*item >= self.start && *item < self.end
}
}

pub trait RangeInclusiveExt<T> {
fn overlaps(&self, other: &Self) -> bool;
fn touches(&self, other: &Self) -> bool
where
T: StepLite + Bounded + Clone;
// TODO: Remove once https://github.com/rust-lang/rust/issues/32311
// is stabilized.
fn contains_item(&self, item: &T) -> bool;
}

impl<T> RangeInclusiveExt<T> for RangeInclusive<T>
Expand Down Expand Up @@ -76,12 +64,6 @@ where
};
max(self.start(), other.start()) <= min(&longer_self_end, &longer_other_end)
}

// TODO: Remove once https://github.com/rust-lang/rust/issues/32311
// is stabilized.
fn contains_item(&self, item: &T) -> bool {
*item >= *self.start() && *item <= *self.end()
}
}

/// Minimal version of unstable [Step](std::iter::Step) trait
Expand Down

0 comments on commit b0e583d

Please sign in to comment.