Skip to content

Commit

Permalink
Make overlapping/overlaps accept ranges by-value instead of by-reference
Browse files Browse the repository at this point in the history
  • Loading branch information
clarfonthey committed Jun 11, 2023
1 parent ea9b2e3 commit 7a26f7e
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
6 changes: 3 additions & 3 deletions src/inclusive_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ where

/// Gets an iterator over all the stored ranges that are
/// either partially or completely overlapped by the given range.
pub fn overlapping<'a>(&'a self, range: &'a RangeInclusive<K>) -> Overlapping<K, V> {
pub fn overlapping<'a>(&'a self, range: RangeInclusive<K>) -> Overlapping<K, V> {
// Find the first matching stored range by its _end_,
// using sneaky layering and `Borrow` implementation. (See `range_wrappers` module.)
let start_sliver =
Expand All @@ -545,7 +545,7 @@ where

/// Returns `true` if any range in the map completely or partially
/// overlaps the given range.
pub fn overlaps(&self, range: &RangeInclusive<K>) -> bool {
pub fn overlaps(&self, range: RangeInclusive<K>) -> bool {
self.overlapping(range).next().is_some()
}
}
Expand Down Expand Up @@ -812,7 +812,7 @@ where
///
/// [`overlapping`]: RangeInclusiveMap::overlapping
pub struct Overlapping<'a, K, V> {
query_range: &'a RangeInclusive<K>,
query_range: RangeInclusive<K>,
btm_range_iter: alloc::collections::btree_map::Range<'a, RangeInclusiveStartWrapper<K>, V>,
}

Expand Down
4 changes: 2 additions & 2 deletions src/inclusive_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,15 +189,15 @@ where
/// either partially or completely overlapped by the given range.
///
/// The iterator element type is `RangeInclusive<T>`.
pub fn overlapping<'a>(&'a self, range: &'a RangeInclusive<T>) -> Overlapping<T> {
pub fn overlapping<'a>(&'a self, range: RangeInclusive<T>) -> Overlapping<T> {
Overlapping {
inner: self.rm.overlapping(range),
}
}

/// Returns `true` if any range in the set completely or partially
/// overlaps the given range.
pub fn overlaps(&self, range: &RangeInclusive<T>) -> bool {
pub fn overlaps(&self, range: RangeInclusive<T>) -> bool {
self.overlapping(range).next().is_some()
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ where

/// Gets an iterator over all the stored ranges that are
/// either partially or completely overlapped by the given range.
pub fn overlapping<'a>(&'a self, range: &'a Range<K>) -> Overlapping<K, V> {
pub fn overlapping<'a>(&'a self, range: Range<K>) -> Overlapping<K, V> {
// Find the first matching stored range by its _end_,
// using sneaky layering and `Borrow` implementation. (See `range_wrappers` module.)
let start_sliver = RangeEndWrapper::new(range.start.clone()..range.start.clone());
Expand All @@ -188,7 +188,7 @@ where

/// Returns `true` if any range in the map completely or partially
/// overlaps the given range.
pub fn overlaps(&self, range: &Range<K>) -> bool {
pub fn overlaps(&self, range: Range<K>) -> bool {
self.overlapping(range).next().is_some()
}
}
Expand Down Expand Up @@ -700,7 +700,7 @@ where
///
/// [`overlapping`]: RangeMap::overlapping
pub struct Overlapping<'a, K, V> {
query_range: &'a Range<K>,
query_range: Range<K>,
btm_range_iter: alloc::collections::btree_map::Range<'a, RangeStartWrapper<K>, V>,
}

Expand Down
4 changes: 2 additions & 2 deletions src/set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,15 +163,15 @@ where
/// either partially or completely overlapped by the given range.
///
/// The iterator element type is `&Range<T>`.
pub fn overlapping<'a>(&'a self, range: &'a Range<T>) -> Overlapping<T> {
pub fn overlapping<'a>(&'a self, range: Range<T>) -> Overlapping<T> {
Overlapping {
inner: self.rm.overlapping(range),
}
}

/// Returns `true` if any range in the set completely or partially
/// overlaps the given range.
pub fn overlaps(&self, range: &Range<T>) -> bool {
pub fn overlaps(&self, range: Range<T>) -> bool {
self.overlapping(range).next().is_some()
}
}
Expand Down

0 comments on commit 7a26f7e

Please sign in to comment.