Skip to content

Commit

Permalink
Add a test for cloned side effects
Browse files Browse the repository at this point in the history
  • Loading branch information
KamilaBorowska committed Dec 5, 2018
1 parent 3eddc74 commit a964307
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/libcore/tests/iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1249,6 +1249,23 @@ fn test_cloned() {
assert_eq!(it.next_back(), None);
}

#[test]
fn test_cloned_side_effects() {
let mut count = 0;
{
let iter = [1, 2, 3]
.iter()
.map(|x| {
count += 1;
x
})
.cloned()
.zip(&[1]);
for _ in iter {}
}
assert_eq!(count, 2);
}

#[test]
fn test_double_ended_map() {
let xs = [1, 2, 3, 4, 5, 6];
Expand Down

0 comments on commit a964307

Please sign in to comment.