Skip to content

Commit

Permalink
Mark the result of BitFlags::iter as Clone (#38)
Browse files Browse the repository at this point in the history
This is already supported by the implementation but wasn't exposed.
  • Loading branch information
akonradi authored Dec 13, 2021
1 parent 2bdcc46 commit 923bede
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,7 @@ where
}

/// Returns an iterator that yields each set flag
pub fn iter(self) -> impl Iterator<Item = T> {
pub fn iter(self) -> impl Iterator<Item = T> + Clone {
T::FLAG_LIST
.iter()
.cloned()
Expand Down
3 changes: 3 additions & 0 deletions test_suite/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ fn iterator() {

for &(bitflag, expected) in tests {
assert!(bitflag.iter().zip(expected.iter().cloned()).all(|(a, b)| a == b));
// If cloned, the iterator will yield the same elements.
let it = bitflag.iter();
assert!(it.clone().zip(it).all(|(a, b)| a == b));
}
}

Expand Down

0 comments on commit 923bede

Please sign in to comment.