Skip to content

Commit

Permalink
fix clippy errors
Browse files Browse the repository at this point in the history
  • Loading branch information
iammadab committed Oct 11, 2023
1 parent 852e85c commit 47182be
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 22 deletions.
15 changes: 1 addition & 14 deletions grovedb/src/batch/key_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,20 +100,7 @@ impl PartialEq<&[u8]> for KeyInfo {
#[cfg(feature = "full")]
impl PartialOrd<Self> for KeyInfo {
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
match self.as_slice().partial_cmp(other.as_slice()) {
None => None,
Some(ord) => match ord {
Ordering::Less => Some(Ordering::Less),
Ordering::Equal => {
let other_len = other.max_length();
match self.max_length().partial_cmp(&other_len) {
None => Some(Ordering::Equal),
Some(ord) => Some(ord),
}
}
Ordering::Greater => Some(Ordering::Greater),
},
}
Some(self.cmp(other))
}
}

Expand Down
16 changes: 8 additions & 8 deletions grovedb/src/batch/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,19 +168,19 @@ pub enum Op {

impl PartialOrd for Op {
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
match (self, other) {
(Op::Delete, Op::Insert { .. }) => Some(Ordering::Less),
(Op::Delete, Op::Replace { .. }) => Some(Ordering::Less),
(Op::Insert { .. }, Op::Delete) => Some(Ordering::Greater),
(Op::Replace { .. }, Op::Delete) => Some(Ordering::Greater),
_ => Some(Ordering::Equal),
}
Some(self.cmp(other))
}
}

impl Ord for Op {
fn cmp(&self, other: &Self) -> Ordering {
self.partial_cmp(other).expect("all ops have order")
match (self, other) {
(Op::Delete, Op::Insert { .. }) => Ordering::Less,
(Op::Delete, Op::Replace { .. }) => Ordering::Less,
(Op::Insert { .. }, Op::Delete) => Ordering::Greater,
(Op::Replace { .. }, Op::Delete) => Ordering::Greater,
_ => Ordering::Equal,
}
}
}

Expand Down

0 comments on commit 47182be

Please sign in to comment.