@@ -1031,7 +1031,7 @@ impl<T, A: Allocator> LinkedList<T, A> {
1031
1031
1032
1032
/// Retains only the elements specified by the predicate.
1033
1033
///
1034
- /// In other words, remove all elements `e` for which `f(&e)` returns false.
1034
+ /// In other words, remove all elements `e` for which `f(&mut e)` returns false.
1035
1035
/// This method operates in place, visiting each element exactly once in the
1036
1036
/// original order, and preserves the order of the retained elements.
1037
1037
///
@@ -1047,7 +1047,7 @@ impl<T, A: Allocator> LinkedList<T, A> {
1047
1047
/// d.push_front(2);
1048
1048
/// d.push_front(3);
1049
1049
///
1050
- /// d.retain(|&x| x % 2 == 0);
1050
+ /// d.retain(|&mut x| x % 2 == 0);
1051
1051
///
1052
1052
/// assert_eq!(d.pop_front(), Some(2));
1053
1053
/// assert_eq!(d.pop_front(), None);
@@ -1074,41 +1074,6 @@ impl<T, A: Allocator> LinkedList<T, A> {
1074
1074
/// ```
1075
1075
#[ unstable( feature = "linked_list_retain" , issue = "114135" ) ]
1076
1076
pub fn retain < F > ( & mut self , mut f : F )
1077
- where
1078
- F : FnMut ( & T ) -> bool ,
1079
- {
1080
- self . retain_mut ( |elem| f ( elem) ) ;
1081
- }
1082
-
1083
- /// Retains only the elements specified by the predicate.
1084
- ///
1085
- /// In other words, remove all elements `e` for which `f(&mut e)` returns false.
1086
- /// This method operates in place, visiting each element exactly once in the
1087
- /// original order, and preserves the order of the retained elements.
1088
- ///
1089
- /// # Examples
1090
- ///
1091
- /// ```
1092
- /// #![feature(linked_list_retain)]
1093
- /// use std::collections::LinkedList;
1094
- ///
1095
- /// let mut d = LinkedList::new();
1096
- ///
1097
- /// d.push_front(1);
1098
- /// d.push_front(2);
1099
- /// d.push_front(3);
1100
- ///
1101
- /// d.retain_mut(|x| if *x % 2 == 0 {
1102
- /// *x += 1;
1103
- /// true
1104
- /// } else {
1105
- /// false
1106
- /// });
1107
- /// assert_eq!(d.pop_front(), Some(3));
1108
- /// assert_eq!(d.pop_front(), None);
1109
- /// ```
1110
- #[ unstable( feature = "linked_list_retain" , issue = "114135" ) ]
1111
- pub fn retain_mut < F > ( & mut self , mut f : F )
1112
1077
where
1113
1078
F : FnMut ( & mut T ) -> bool ,
1114
1079
{
0 commit comments