diff options
| author | Joshua Gentry <pixel@deathbysoftware.com> | 2025-07-06 10:40:55 -0400 |
|---|---|---|
| committer | Joshua Gentry <pixel@deathbysoftware.com> | 2025-07-06 10:40:55 -0400 |
| commit | 39575d39c5663af91c327fe33f9459e312d96ae0 (patch) | |
| tree | ada57c71917d7559594d4c8d174bd7f91b65432a | |
| parent | c83e217d268d25960a0c79c6941bcb3917a6a0af (diff) | |
| download | rust-39575d39c5663af91c327fe33f9459e312d96ae0.tar.gz rust-39575d39c5663af91c327fe33f9459e312d96ae0.zip | |
Renamed retain_mut to retain on LinkedList as mentioned in the ACP
| -rw-r--r-- | library/alloc/src/collections/linked_list.rs | 39 |
1 files changed, 2 insertions, 37 deletions
diff --git a/library/alloc/src/collections/linked_list.rs b/library/alloc/src/collections/linked_list.rs index d03c1969b5b..70c344e49b7 100644 --- a/library/alloc/src/collections/linked_list.rs +++ b/library/alloc/src/collections/linked_list.rs @@ -1031,7 +1031,7 @@ impl<T, A: Allocator> LinkedList<T, A> { /// Retains only the elements specified by the predicate. /// - /// In other words, remove all elements `e` for which `f(&e)` returns false. + /// In other words, remove all elements `e` for which `f(&mut e)` returns false. /// This method operates in place, visiting each element exactly once in the /// original order, and preserves the order of the retained elements. /// @@ -1047,7 +1047,7 @@ impl<T, A: Allocator> LinkedList<T, A> { /// d.push_front(2); /// d.push_front(3); /// - /// d.retain(|&x| x % 2 == 0); + /// d.retain(|&mut x| x % 2 == 0); /// /// assert_eq!(d.pop_front(), Some(2)); /// assert_eq!(d.pop_front(), None); @@ -1075,41 +1075,6 @@ impl<T, A: Allocator> LinkedList<T, A> { #[unstable(feature = "linked_list_retain", issue = "114135")] pub fn retain<F>(&mut self, mut f: F) where - F: FnMut(&T) -> bool, - { - self.retain_mut(|elem| f(elem)); - } - - /// Retains only the elements specified by the predicate. - /// - /// In other words, remove all elements `e` for which `f(&mut e)` returns false. - /// This method operates in place, visiting each element exactly once in the - /// original order, and preserves the order of the retained elements. - /// - /// # Examples - /// - /// ``` - /// #![feature(linked_list_retain)] - /// use std::collections::LinkedList; - /// - /// let mut d = LinkedList::new(); - /// - /// d.push_front(1); - /// d.push_front(2); - /// d.push_front(3); - /// - /// d.retain_mut(|x| if *x % 2 == 0 { - /// *x += 1; - /// true - /// } else { - /// false - /// }); - /// assert_eq!(d.pop_front(), Some(3)); - /// assert_eq!(d.pop_front(), None); - /// ``` - #[unstable(feature = "linked_list_retain", issue = "114135")] - pub fn retain_mut<F>(&mut self, mut f: F) - where F: FnMut(&mut T) -> bool, { let mut cursor = self.cursor_front_mut(); |
