Skip to content

Commit

Permalink
chore: remove unreachable excluded range
Browse files Browse the repository at this point in the history
  • Loading branch information
vincent-herlemont committed Sep 1, 2024
1 parent 7e0d719 commit a0b2e8c
Showing 1 changed file with 8 additions and 20 deletions.
28 changes: 8 additions & 20 deletions src/db_type/key/key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ impl Key {
Self(data)
}

pub(crate) fn extend(&mut self, data: &Key) {
self.0.extend(data.0.iter());
}

pub fn extend_with_delimiter(&mut self, delimiter: u8, data: &Key) {
self.0.push(delimiter);
self.0.extend(data.0.iter());
Expand Down Expand Up @@ -340,31 +336,23 @@ impl KeyRange {
{
match (bounds.start_bound(), bounds.end_bound()) {
(Bound::Included(start), Bound::Included(end)) => {
let start = start.to_key();
let mut end = end.to_key();
// Add 255 to the end key to include the last key
end.extend(&Key::new(vec![255]));
KeyRange::RangeInclusive(start..=end)
KeyRange::RangeInclusive(start.to_key()..=end.to_key())
}
(Bound::Included(start), Bound::Excluded(end)) => {
KeyRange::Range(start.to_key()..end.to_key())
}
(Bound::Included(start), Bound::Unbounded) => KeyRange::RangeFrom(RangeFrom {
start: start.to_key(),
}),
(Bound::Excluded(start), Bound::Included(end)) => {
let start = start.to_key();
let mut end = end.to_key();
// Add 255 to the end key to include the last key
end.extend(&Key::new(vec![255]));
KeyRange::RangeInclusive(start..=end)
(Bound::Excluded(_), Bound::Included(_)) => {
unreachable!("Excluded => Included bound is not supported")
}
(Bound::Excluded(start), Bound::Excluded(end)) => {
KeyRange::Range(start.to_key()..end.to_key())
(Bound::Excluded(_), Bound::Excluded(_)) => {
unreachable!("Excluded => Excluded bound is not supported")
}
(Bound::Excluded(_), Bound::Unbounded) => {
unreachable!("Excluded => Unbounded bound is not supported")
}
(Bound::Excluded(start), Bound::Unbounded) => KeyRange::RangeFrom(RangeFrom {
start: start.to_key(),
}),
(Bound::Unbounded, Bound::Included(end)) => KeyRange::RangeTo(RangeTo {
end: { end.to_key() },
}),
Expand Down

0 comments on commit a0b2e8c

Please sign in to comment.