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).
This commit is contained in:
commit
fb4f015ea3
1 changed files with 4 additions and 4 deletions
|
@ -2003,7 +2003,7 @@ pub trait Iterator {
|
||||||
/// a.iter().map(|&x| x * 2).collect_into(&mut vec);
|
/// a.iter().map(|&x| x * 2).collect_into(&mut vec);
|
||||||
/// a.iter().map(|&x| x * 10).collect_into(&mut vec);
|
/// a.iter().map(|&x| x * 10).collect_into(&mut vec);
|
||||||
///
|
///
|
||||||
/// assert_eq!(vec![0, 1, 2, 4, 6, 10, 20, 30], vec);
|
/// assert_eq!(vec, vec![0, 1, 2, 4, 6, 10, 20, 30]);
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// `Vec` can have a manual set capacity to avoid reallocating it:
|
/// `Vec` can have a manual set capacity to avoid reallocating it:
|
||||||
|
@ -2018,7 +2018,7 @@ pub trait Iterator {
|
||||||
/// a.iter().map(|&x| x * 10).collect_into(&mut vec);
|
/// a.iter().map(|&x| x * 10).collect_into(&mut vec);
|
||||||
///
|
///
|
||||||
/// assert_eq!(6, vec.capacity());
|
/// assert_eq!(6, vec.capacity());
|
||||||
/// println!("{:?}", vec);
|
/// assert_eq!(vec, vec![2, 4, 6, 10, 20, 30]);
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// The returned mutable reference can be used to continue the call chain:
|
/// The returned mutable reference can be used to continue the call chain:
|
||||||
|
@ -2032,12 +2032,12 @@ pub trait Iterator {
|
||||||
/// let count = a.iter().collect_into(&mut vec).iter().count();
|
/// let count = a.iter().collect_into(&mut vec).iter().count();
|
||||||
///
|
///
|
||||||
/// assert_eq!(count, vec.len());
|
/// assert_eq!(count, vec.len());
|
||||||
/// println!("Vec len is {}", count);
|
/// assert_eq!(vec, vec![1, 2, 3]);
|
||||||
///
|
///
|
||||||
/// let count = a.iter().collect_into(&mut vec).iter().count();
|
/// let count = a.iter().collect_into(&mut vec).iter().count();
|
||||||
///
|
///
|
||||||
/// assert_eq!(count, vec.len());
|
/// assert_eq!(count, vec.len());
|
||||||
/// println!("Vec len now is {}", count);
|
/// assert_eq!(vec, vec![1, 2, 3, 1, 2, 3]);
|
||||||
/// ```
|
/// ```
|
||||||
#[inline]
|
#[inline]
|
||||||
#[unstable(feature = "iter_collect_into", reason = "new API", issue = "94780")]
|
#[unstable(feature = "iter_collect_into", reason = "new API", issue = "94780")]
|
||||||
|
|
Loading…
Add table
Reference in a new issue