diff options
| author | Corey Farwell <coreyf@rwell.org> | 2016-07-30 23:21:48 -0400 |
|---|---|---|
| committer | Corey Farwell <coreyf@rwell.org> | 2016-07-30 23:21:48 -0400 |
| commit | 2eea1f3097a303378b2cd2870fecde853bb884b3 (patch) | |
| tree | 213155a49336fac6375e54e99cda1847e67bc8c5 | |
| parent | 1225e122fda8cfbe3a5da6007e912f204b97f8c4 (diff) | |
| download | rust-2eea1f3097a303378b2cd2870fecde853bb884b3.tar.gz rust-2eea1f3097a303378b2cd2870fecde853bb884b3.zip | |
Rewrite `slice::chunks` doc example to not require printing.
| -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] |
