Rollup merge of #35134 - frewsxcv:slice-chunks, r=GuillaumeGomez
Rewrite `slice::chunks` doc example to not require printing. None
This commit is contained in:
commit
2effa8982e
1 changed files with 7 additions and 9 deletions
|
@ -577,15 +577,13 @@ impl<T> [T] {
|
||||||
///
|
///
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// Print the slice two elements at a time (i.e. `[1,2]`,
|
/// ```
|
||||||
/// `[3,4]`, `[5]`):
|
/// let slice = ['l', 'o', 'r', 'e', 'm'];
|
||||||
///
|
/// let mut iter = slice.chunks(2);
|
||||||
/// ```rust
|
/// assert_eq!(iter.next().unwrap(), &['l', 'o']);
|
||||||
/// let v = &[1, 2, 3, 4, 5];
|
/// assert_eq!(iter.next().unwrap(), &['r', 'e']);
|
||||||
///
|
/// assert_eq!(iter.next().unwrap(), &['m']);
|
||||||
/// for chunk in v.chunks(2) {
|
/// assert!(iter.next().is_none());
|
||||||
/// println!("{:?}", chunk);
|
|
||||||
/// }
|
|
||||||
/// ```
|
/// ```
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
#[inline]
|
#[inline]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue