From 7a26f7eece30a1eb937d1cdbb702dd9d0bf40523 Mon Sep 17 00:00:00 2001 From: ltdk Date: Sun, 11 Jun 2023 16:39:04 -0400 Subject: [PATCH] Make overlapping/overlaps accept ranges by-value instead of by-reference --- src/inclusive_map.rs | 6 +++--- src/inclusive_set.rs | 4 ++-- src/map.rs | 6 +++--- src/set.rs | 4 ++-- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/inclusive_map.rs b/src/inclusive_map.rs index 76e6e09..ea73269 100644 --- a/src/inclusive_map.rs +++ b/src/inclusive_map.rs @@ -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) -> Overlapping { + pub fn overlapping<'a>(&'a self, range: RangeInclusive) -> Overlapping { // Find the first matching stored range by its _end_, // using sneaky layering and `Borrow` implementation. (See `range_wrappers` module.) let start_sliver = @@ -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) -> bool { + pub fn overlaps(&self, range: RangeInclusive) -> bool { self.overlapping(range).next().is_some() } } @@ -812,7 +812,7 @@ where /// /// [`overlapping`]: RangeInclusiveMap::overlapping pub struct Overlapping<'a, K, V> { - query_range: &'a RangeInclusive, + query_range: RangeInclusive, btm_range_iter: alloc::collections::btree_map::Range<'a, RangeInclusiveStartWrapper, V>, } diff --git a/src/inclusive_set.rs b/src/inclusive_set.rs index fcc73c4..2a2cba7 100644 --- a/src/inclusive_set.rs +++ b/src/inclusive_set.rs @@ -189,7 +189,7 @@ where /// either partially or completely overlapped by the given range. /// /// The iterator element type is `RangeInclusive`. - pub fn overlapping<'a>(&'a self, range: &'a RangeInclusive) -> Overlapping { + pub fn overlapping<'a>(&'a self, range: RangeInclusive) -> Overlapping { Overlapping { inner: self.rm.overlapping(range), } @@ -197,7 +197,7 @@ where /// Returns `true` if any range in the set completely or partially /// overlaps the given range. - pub fn overlaps(&self, range: &RangeInclusive) -> bool { + pub fn overlaps(&self, range: RangeInclusive) -> bool { self.overlapping(range).next().is_some() } } diff --git a/src/map.rs b/src/map.rs index bdad204..d97c5af 100644 --- a/src/map.rs +++ b/src/map.rs @@ -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) -> Overlapping { + pub fn overlapping<'a>(&'a self, range: Range) -> Overlapping { // 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()); @@ -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) -> bool { + pub fn overlaps(&self, range: Range) -> bool { self.overlapping(range).next().is_some() } } @@ -700,7 +700,7 @@ where /// /// [`overlapping`]: RangeMap::overlapping pub struct Overlapping<'a, K, V> { - query_range: &'a Range, + query_range: Range, btm_range_iter: alloc::collections::btree_map::Range<'a, RangeStartWrapper, V>, } diff --git a/src/set.rs b/src/set.rs index 5947b21..935d6fe 100644 --- a/src/set.rs +++ b/src/set.rs @@ -163,7 +163,7 @@ where /// either partially or completely overlapped by the given range. /// /// The iterator element type is `&Range`. - pub fn overlapping<'a>(&'a self, range: &'a Range) -> Overlapping { + pub fn overlapping<'a>(&'a self, range: Range) -> Overlapping { Overlapping { inner: self.rm.overlapping(range), } @@ -171,7 +171,7 @@ where /// Returns `true` if any range in the set completely or partially /// overlaps the given range. - pub fn overlaps(&self, range: &Range) -> bool { + pub fn overlaps(&self, range: Range) -> bool { self.overlapping(range).next().is_some() } }