Skip to content

Commit

Permalink
Merge pull request #216 from superfell/vec_order
Browse files Browse the repository at this point in the history
Fix BitVec to BitSlice partial_cmp. Fixes #215
  • Loading branch information
myrrlyn committed Apr 12, 2023
2 parents 96baa43 + f3d5b43 commit 0e8cdf6
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
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
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 0e8cdf6

Please sign in to comment.