refactor: cleanup iterator lifetimes and unnecessary method calls
@@ -60,7 +60,7 @@ where
}
pub fn len(&self) -> u64 {
- self.tree.len() as u64
+ self.tree.len()
}
pub fn clear(&mut self) {
@@ -145,23 +145,23 @@ where
}
/// Iterate all entries in ascending order: min to max, both inclusive
- pub fn iter<'a>(&'a self) -> impl Iterator<Item = (K, V)> + 'a {
- Cursor::asc(&self).into_iter()
+ pub fn iter(&self) -> impl Iterator<Item = (K, V)> + '_ {
+ Cursor::asc(&self)
}
/// Iterate entries in ascending order: given key (exclusive) to max (inclusive)
- pub fn iter_from<'a>(&'a self, key: K) -> impl Iterator<Item = (K, V)> + 'a {
- Cursor::asc_from(&self, key).into_iter()
+ pub fn iter_from(&self, key: K) -> impl Iterator<Item = (K, V)> + '_ {
+ Cursor::asc_from(&self, key)
}
/// Iterate all entries in descending order: max to min, both inclusive
- pub fn iter_rev<'a>(&'a self) -> impl Iterator<Item = (K, V)> + 'a {
- Cursor::desc(&self).into_iter()
+ pub fn iter_rev(&self) -> impl Iterator<Item = (K, V)> + '_ {
+ Cursor::desc(&self)
}
/// Iterate entries in descending order: given key (exclusive) to min (inclusive)
- pub fn iter_rev_from<'a>(&'a self, key: K) -> impl Iterator<Item = (K, V)> + 'a {
- Cursor::desc_from(&self, key).into_iter()
+ pub fn iter_rev_from(&self, key: K) -> impl Iterator<Item = (K, V)> + '_ {
+ Cursor::desc_from(&self, key)
}
/// Iterate entries in ascending order according to specified bounds.
@@ -170,7 +170,7 @@ where
///
/// Panics if range start > end.
/// Panics if range start == end and both bounds are Excluded.
- pub fn range<'a>(&'a self, r: (Bound<K>, Bound<K>)) -> impl Iterator<Item = (K, V)> + 'a {
+ pub fn range(&self, r: (Bound<K>, Bound<K>)) -> impl Iterator<Item = (K, V)> + '_ {
let (lo, hi) = match r {
(Bound::Included(a), Bound::Included(b)) if a > b => panic!("Invalid range."),
(Bound::Excluded(a), Bound::Included(b)) if a > b => panic!("Invalid range."),
@@ -179,7 +179,7 @@ where
(lo, hi) => (lo, hi),
};
- Cursor::range(&self, lo, hi).into_iter()
+ Cursor::range(&self, lo, hi)
}
/// Helper function which creates a [`Vec<(K, V)>`] of all items in the [`LegacyTreeMap`].
