Skip to content

Commit 7cb4e51

Browse files
the8472SkiFire13
andcommitted
from review: more robust test
This also checks the contents and not only the capacity in case IntoIter's clone implementation is changed to add capacity at the end. Extra capacity at the beginning would be needed to make InPlaceIterable work. Co-authored-by: Giacomo Stevanato <[email protected]>
1 parent a44a059 commit 7cb4e51

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

library/alloc/tests/vec.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1100,12 +1100,12 @@ fn test_from_iter_specialization_panic_during_drop_leaks() {
11001100
#[test]
11011101
fn test_collect_after_iterator_clone() {
11021102
let v = vec![0; 5];
1103-
let mut i = v.into_iter().peekable();
1103+
let mut i = v.into_iter().map(|i| i + 1).peekable();
11041104
i.peek();
11051105
let v = i.clone().collect::<Vec<_>>();
1106+
assert_eq!(v, [1, 1, 1, 1, 1]);
11061107
assert!(v.len() <= v.capacity());
11071108
}
1108-
11091109
#[test]
11101110
fn test_cow_from() {
11111111
let borrowed: &[_] = &["borrowed", "(slice)"];

0 commit comments

Comments
 (0)