Add a test for cloned side effects

This commit is contained in:
Konrad Borowski 2018-12-05 17:53:34 +01:00
parent 3eddc743f2
commit a964307999
1 changed files with 17 additions and 0 deletions

View File

@ -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];