Skip to content

Commit

Permalink
Fix BitVec to BitSlice partial_cmp. Fixes #215
Browse files Browse the repository at this point in the history
  • Loading branch information
superfell committed Jan 29, 2023
1 parent 96baa43 commit f3d5b43
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
16 changes: 16 additions & 0 deletions src/vec/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,19 @@ fn misc() {

assert_eq!(!bitvec![0, 1], bits![1, 0]);
}

#[test]
fn bitvec_order() {
let k = bitvec![0, 1, 0, 1];
let r = bitvec![1, 0, 0, 0];
let k_slice = &k[..];
let r_slice = &r[..];
assert!(r > k);
assert!(k < r);
assert!(r_slice > k_slice);
assert!(k_slice < r_slice);
assert!(r_slice > k);
assert!(k < r_slice);
assert!(k_slice < r);
assert!(r > k_slice);
}
2 changes: 1 addition & 1 deletion src/vec/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ where
{
#[inline]
fn partial_cmp(&self, other: &Rhs) -> Option<cmp::Ordering> {
other.partial_cmp(self.as_bitslice())
other.partial_cmp(self.as_bitslice()).map(|o| o.reverse())
}
}

Expand Down

0 comments on commit f3d5b43

Please sign in to comment.