summaryrefslogtreecommitdiffstats
path: root/vendor/litemap/src/store
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-07 05:48:48 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-07 05:48:48 +0000
commitef24de24a82fe681581cc130f342363c47c0969a (patch)
tree0d494f7e1a38b95c92426f58fe6eaa877303a86c /vendor/litemap/src/store
parentReleasing progress-linux version 1.74.1+dfsg1-1~progress7.99u1. (diff)
downloadrustc-ef24de24a82fe681581cc130f342363c47c0969a.tar.xz
rustc-ef24de24a82fe681581cc130f342363c47c0969a.zip
Merging upstream version 1.75.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/litemap/src/store')
-rw-r--r--vendor/litemap/src/store/mod.rs11
-rw-r--r--vendor/litemap/src/store/slice_impl.rs8
-rw-r--r--vendor/litemap/src/store/vec_impl.rs8
3 files changed, 25 insertions, 2 deletions
diff --git a/vendor/litemap/src/store/mod.rs b/vendor/litemap/src/store/mod.rs
index 3468ebb97..ca696a1af 100644
--- a/vendor/litemap/src/store/mod.rs
+++ b/vendor/litemap/src/store/mod.rs
@@ -30,6 +30,7 @@ use core::cmp::Ordering;
use core::iter::DoubleEndedIterator;
use core::iter::FromIterator;
use core::iter::Iterator;
+use core::ops::Range;
/// Trait to enable const construction of empty store.
pub trait StoreConstEmpty<K: ?Sized, V: ?Sized> {
@@ -53,7 +54,7 @@ pub trait Store<K: ?Sized, V: ?Sized>: Sized {
/// Gets a key/value pair at the specified index.
fn lm_get(&self, index: usize) -> Option<(&K, &V)>;
- /// Gets the last element in the store, or None if the store is empty.
+ /// Gets the last element in the store, or `None` if the store is empty.
fn lm_last(&self) -> Option<(&K, &V)> {
let len = self.lm_len();
if len == 0 {
@@ -76,6 +77,12 @@ pub trait StoreFromIterable<K, V>: Store<K, V> {
fn lm_sort_from_iter<I: IntoIterator<Item = (K, V)>>(iter: I) -> Self;
}
+pub trait StoreSlice<K: ?Sized, V: ?Sized>: Store<K, V> {
+ type Slice: ?Sized;
+
+ fn lm_get_range(&self, range: Range<usize>) -> Option<&Self::Slice>;
+}
+
pub trait StoreMut<K, V>: Store<K, V> {
/// Creates a new store with the specified capacity hint.
///
@@ -129,7 +136,7 @@ pub trait StoreMut<K, V>: Store<K, V> {
}
/// Iterator methods for the LiteMap store.
-pub trait StoreIterable<'a, K: 'a, V: 'a>: Store<K, V> {
+pub trait StoreIterable<'a, K: 'a + ?Sized, V: 'a + ?Sized>: Store<K, V> {
type KeyValueIter: Iterator<Item = (&'a K, &'a V)> + DoubleEndedIterator + 'a;
/// Returns an iterator over key/value pairs.
diff --git a/vendor/litemap/src/store/slice_impl.rs b/vendor/litemap/src/store/slice_impl.rs
index 4afb4fac2..48f6ca40c 100644
--- a/vendor/litemap/src/store/slice_impl.rs
+++ b/vendor/litemap/src/store/slice_impl.rs
@@ -45,6 +45,14 @@ impl<'a, K: 'a, V: 'a> Store<K, V> for &'a [(K, V)] {
}
}
+impl<'a, K, V> StoreSlice<K, V> for &'a [(K, V)] {
+ type Slice = [(K, V)];
+
+ fn lm_get_range(&self, range: Range<usize>) -> Option<&Self::Slice> {
+ self.get(range)
+ }
+}
+
impl<'a, K: 'a, V: 'a> StoreIterable<'a, K, V> for &'a [(K, V)] {
type KeyValueIter = core::iter::Map<core::slice::Iter<'a, (K, V)>, MapF<K, V>>;
diff --git a/vendor/litemap/src/store/vec_impl.rs b/vendor/litemap/src/store/vec_impl.rs
index 361b926c3..2205e8e8f 100644
--- a/vendor/litemap/src/store/vec_impl.rs
+++ b/vendor/litemap/src/store/vec_impl.rs
@@ -53,6 +53,14 @@ impl<K, V> Store<K, V> for Vec<(K, V)> {
}
}
+impl<K, V> StoreSlice<K, V> for Vec<(K, V)> {
+ type Slice = [(K, V)];
+
+ fn lm_get_range(&self, range: Range<usize>) -> Option<&Self::Slice> {
+ self.get(range)
+ }
+}
+
impl<K, V> StoreMut<K, V> for Vec<(K, V)> {
#[inline]
fn lm_with_capacity(capacity: usize) -> Self {