Skip to content

Commit 923bede

Browse files
authored
Mark the result of BitFlags::iter as Clone (#38)
This is already supported by the implementation but wasn't exposed.
1 parent 2bdcc46 commit 923bede

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -601,7 +601,7 @@ where
601601
}
602602

603603
/// Returns an iterator that yields each set flag
604-
pub fn iter(self) -> impl Iterator<Item = T> {
604+
pub fn iter(self) -> impl Iterator<Item = T> + Clone {
605605
T::FLAG_LIST
606606
.iter()
607607
.cloned()

test_suite/common.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,9 @@ fn iterator() {
8787

8888
for &(bitflag, expected) in tests {
8989
assert!(bitflag.iter().zip(expected.iter().cloned()).all(|(a, b)| a == b));
90+
// If cloned, the iterator will yield the same elements.
91+
let it = bitflag.iter();
92+
assert!(it.clone().zip(it).all(|(a, b)| a == b));
9093
}
9194
}
9295

0 commit comments

Comments
 (0)