Skip to content

Commit 5ccba2a

Browse files
committed
Add is_sorted() implementation.
Note: This requires bumping the MSRV to 1.82.0.
1 parent 03644e3 commit 5ccba2a

File tree

5 files changed

+25
-3
lines changed

5 files changed

+25
-3
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ documentation = "https://docs.rs/bit-iter"
99
repository = "https://github.com/ctamblyn/bit-iter"
1010
keywords = ["bits", "flags", "iterator", "bit-twiddling"]
1111
categories = ["algorithms", "no-std"]
12-
rust-version = "1.53.0"
12+
rust-version = "1.82.0"
1313

1414
[dependencies]

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ Bit 0 is set.
4444

4545
## Minimum supported Rust version (MSRV) policy
4646

47-
`bit-iter`'s current minimum supported Rust version (MSRV) is **1.53.0**.
47+
`bit-iter`'s current minimum supported Rust version (MSRV) is **1.82.0**.
4848

4949
`bit-iter` is guaranteed to compile with that version. It might also compile
5050
with older versions, but that could change in a future patch release.

clippy.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
msrv = "1.53.0"
1+
msrv = "1.82.0"

src/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,10 @@ macro_rules! iter_impl {
181181
None
182182
}
183183
}
184+
185+
fn is_sorted(self) -> bool {
186+
true
187+
}
184188
}
185189

186190
/// `FusedIterator` implementation for `BitIter`.

src/tests.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,3 +139,21 @@ fn can_iterate_in_reverse_order() {
139139
assert_eq!(iter.next(), Some(0));
140140
assert_eq!(iter.next(), None);
141141
}
142+
143+
#[test]
144+
fn is_sorted_works() {
145+
let iter = BitIter::from(0x55_u8);
146+
assert!(iter.is_sorted());
147+
148+
let iter = BitIter::from(0x5555_u16);
149+
assert!(iter.is_sorted());
150+
151+
let iter = BitIter::from(0x55555555_u32);
152+
assert!(iter.is_sorted());
153+
154+
let iter = BitIter::from(0x5555555555555555_u64);
155+
assert!(iter.is_sorted());
156+
157+
let iter = BitIter::from(0x55555555555555555555555555555555_u128);
158+
assert!(iter.is_sorted());
159+
}

0 commit comments

Comments
 (0)