Skip to content

Commit

Permalink
from review: more robust test
Browse files Browse the repository at this point in the history
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 <giaco.stevanato@gmail.com>
  • Loading branch information
the8472 and SkiFire13 committed May 18, 2021
1 parent a44a059 commit 7cb4e51
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions library/alloc/tests/vec.rs
Expand Up @@ -1100,12 +1100,12 @@ fn test_from_iter_specialization_panic_during_drop_leaks() {
#[test]
fn test_collect_after_iterator_clone() {
let v = vec![0; 5];
let mut i = v.into_iter().peekable();
let mut i = v.into_iter().map(|i| i + 1).peekable();
i.peek();
let v = i.clone().collect::<Vec<_>>();
assert_eq!(v, [1, 1, 1, 1, 1]);
assert!(v.len() <= v.capacity());
}

#[test]
fn test_cow_from() {
let borrowed: &[_] = &["borrowed", "(slice)"];
Expand Down

0 comments on commit 7cb4e51

Please sign in to comment.