diff options
| author | Seo Sanghyeon <sanxiyn@gmail.com> | 2016-08-02 00:12:40 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2016-08-02 00:12:40 +0900 |
| commit | 2effa8982e5b09351ed93a132a5b0962245ea68a (patch) | |
| tree | 589489c3cad213c63afd08dc2b699c25bf43a6f8 /src | |
| parent | 518524de1ab6ea48dc23479fc002d3ce60e1c057 (diff) | |
| parent | 2eea1f3097a303378b2cd2870fecde853bb884b3 (diff) | |
| download | rust-2effa8982e5b09351ed93a132a5b0962245ea68a.tar.gz rust-2effa8982e5b09351ed93a132a5b0962245ea68a.zip | |
Rollup merge of #35134 - frewsxcv:slice-chunks, r=GuillaumeGomez
Rewrite `slice::chunks` doc example to not require printing. None
Diffstat (limited to 'src')
| -rw-r--r-- | src/libcollections/slice.rs | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/src/libcollections/slice.rs b/src/libcollections/slice.rs index ccef6c02f9d..ff2b8cdea22 100644 --- a/src/libcollections/slice.rs +++ b/src/libcollections/slice.rs @@ -577,15 +577,13 @@ impl<T> [T] { /// /// # Example /// - /// Print the slice two elements at a time (i.e. `[1,2]`, - /// `[3,4]`, `[5]`): - /// - /// ```rust - /// let v = &[1, 2, 3, 4, 5]; - /// - /// for chunk in v.chunks(2) { - /// println!("{:?}", chunk); - /// } + /// ``` + /// let slice = ['l', 'o', 'r', 'e', 'm']; + /// let mut iter = slice.chunks(2); + /// assert_eq!(iter.next().unwrap(), &['l', 'o']); + /// assert_eq!(iter.next().unwrap(), &['r', 'e']); + /// assert_eq!(iter.next().unwrap(), &['m']); + /// assert!(iter.next().is_none()); /// ``` #[stable(feature = "rust1", since = "1.0.0")] #[inline] |
