Skip to content

Commit fb4f015

Browse files
authored
Rollup merge of #109337 - frengor:collect_into_doc, r=scottmcm
Improve `Iterator::collect_into` documentation This improves the examples in the documentation of `Iterator::collect_into`, replacing the usages of `println!` with `assert_eq!` as suggested on [IRLO](https://internals.rust-lang.org/t/18534/9).
2 parents 272afbe + 0c51d0d commit fb4f015

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

library/core/src/iter/traits/iterator.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2003,7 +2003,7 @@ pub trait Iterator {
20032003
/// a.iter().map(|&x| x * 2).collect_into(&mut vec);
20042004
/// a.iter().map(|&x| x * 10).collect_into(&mut vec);
20052005
///
2006-
/// assert_eq!(vec![0, 1, 2, 4, 6, 10, 20, 30], vec);
2006+
/// assert_eq!(vec, vec![0, 1, 2, 4, 6, 10, 20, 30]);
20072007
/// ```
20082008
///
20092009
/// `Vec` can have a manual set capacity to avoid reallocating it:
@@ -2018,7 +2018,7 @@ pub trait Iterator {
20182018
/// a.iter().map(|&x| x * 10).collect_into(&mut vec);
20192019
///
20202020
/// assert_eq!(6, vec.capacity());
2021-
/// println!("{:?}", vec);
2021+
/// assert_eq!(vec, vec![2, 4, 6, 10, 20, 30]);
20222022
/// ```
20232023
///
20242024
/// The returned mutable reference can be used to continue the call chain:
@@ -2032,12 +2032,12 @@ pub trait Iterator {
20322032
/// let count = a.iter().collect_into(&mut vec).iter().count();
20332033
///
20342034
/// assert_eq!(count, vec.len());
2035-
/// println!("Vec len is {}", count);
2035+
/// assert_eq!(vec, vec![1, 2, 3]);
20362036
///
20372037
/// let count = a.iter().collect_into(&mut vec).iter().count();
20382038
///
20392039
/// assert_eq!(count, vec.len());
2040-
/// println!("Vec len now is {}", count);
2040+
/// assert_eq!(vec, vec![1, 2, 3, 1, 2, 3]);
20412041
/// ```
20422042
#[inline]
20432043
#[unstable(feature = "iter_collect_into", reason = "new API", issue = "94780")]

0 commit comments

Comments
 (0)