Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
marvin-j97 committed Dec 7, 2024
1 parent 26c6072 commit f4b745c
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/key_range.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,18 +65,21 @@ impl KeyRange {
true
}

/// Returns `true` if the key falls within this key range.
pub fn contains_key<K: AsRef<[u8]>>(&self, key: K) -> bool {
let key = key.as_ref();
let (start, end) = &self.0;
key >= *start && key <= *end
}

/// Returns `true` if the `other` is fully contained in this range.
pub fn contains_range(&self, other: &Self) -> bool {
let (start1, end1) = &self.0;
let (start2, end2) = &other.0;
start1 <= start2 && end1 >= end2
}

/// Returns `true` if the `other` overlaps at least partially with this range.
pub fn overlaps_with_key_range(&self, other: &Self) -> bool {
let (start1, end1) = &self.0;
let (start2, end2) = &other.0;
Expand Down

0 comments on commit f4b745c

Please sign in to comment.