about summary refs log tree commit diff
diff options
context:
space:
mode:
authorthe8472 <the8472@users.noreply.github.com>2021-05-16 15:35:05 +0200
committerThe8472 <git@infinite-source.de>2021-05-19 01:41:12 +0200
commit7cb4e5180f16ad83d39da9555561360add5fb22d (patch)
treee81d5cdbbb6f1220ed7f864f8bb8447c2afcc056
parenta44a059c3b65b5ce9c996db0995eb574e46fa314 (diff)
downloadrust-7cb4e5180f16ad83d39da9555561360add5fb22d.tar.gz
rust-7cb4e5180f16ad83d39da9555561360add5fb22d.zip
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 <giaco.stevanato@gmail.com>
-rw-r--r--library/alloc/tests/vec.rs4
1 files changed, 2 insertions, 2 deletions
diff --git a/library/alloc/tests/vec.rs b/library/alloc/tests/vec.rs
index 6c71cf924d2..ad69234403b 100644
--- a/library/alloc/tests/vec.rs
+++ b/library/alloc/tests/vec.rs
@@ -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)"];