diff options
| author | Camelid <camelidcamel@gmail.com> | 2021-03-20 14:09:38 -0700 |
|---|---|---|
| committer | Camelid <camelidcamel@gmail.com> | 2021-03-20 14:09:38 -0700 |
| commit | 49ccc3f320a4728b80f393d8a60fa4466f8a4c0c (patch) | |
| tree | 62c23fdcb04e85b30fe75e8eda45d7548ea51137 | |
| parent | c1df9f1b6b59733ff94f2b74e943ab669c06c67d (diff) | |
| download | rust-49ccc3f320a4728b80f393d8a60fa4466f8a4c0c.tar.gz rust-49ccc3f320a4728b80f393d8a60fa4466f8a4c0c.zip | |
Remove redundant second example
| -rw-r--r-- | library/core/src/iter/traits/iterator.rs | 28 |
1 files changed, 0 insertions, 28 deletions
diff --git a/library/core/src/iter/traits/iterator.rs b/library/core/src/iter/traits/iterator.rs index d5e5b4ca16c..6d211d77952 100644 --- a/library/core/src/iter/traits/iterator.rs +++ b/library/core/src/iter/traits/iterator.rs @@ -1549,34 +1549,6 @@ pub trait Iterator { /// let of_rust: Vec<_> = words.collect(); /// assert_eq!(of_rust, vec!["of", "Rust"]); /// ``` - /// - /// This demonstrates a use case that needs `by_ref`: - /// - /// ```compile_fail,E0382 - /// let a = [1, 2, 3, 4, 5]; - /// let mut iter = a.iter(); - /// - /// let sum: i32 = iter.take(3).fold(0, |acc, i| acc + i); - /// assert_eq!(sum, 6); - /// - /// // Error! We can't use `iter` again because it was moved - /// // by `take`. - /// assert_eq!(iter.next(), Some(&4)); - /// ``` - /// - /// Now, let's use `by_ref` to make this work: - /// - /// ``` - /// let a = [1, 2, 3, 4, 5]; - /// let mut iter = a.iter(); - /// - /// // We add in a call to `by_ref` here so `iter` isn't moved. - /// let sum: i32 = iter.by_ref().take(3).fold(0, |acc, i| acc + i); - /// assert_eq!(sum, 6); - /// - /// // And now we can use `iter` again because we still own it. - /// assert_eq!(iter.next(), Some(&4)); - /// ``` #[stable(feature = "rust1", since = "1.0.0")] fn by_ref(&mut self) -> &mut Self where |
