File tree 1 file changed +8
-2
lines changed 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -161,7 +161,7 @@ impl<T> Option<T> {
161
161
162
162
/// Filters an optional value using given function.
163
163
#[ inline( always) ]
164
- pub fn filtered < ' a > ( self , f : & fn ( t : & ' a T ) -> bool ) -> Option < T > {
164
+ pub fn filtered ( self , f : & fn ( t : & T ) -> bool ) -> Option < T > {
165
165
match self {
166
166
Some ( x) => if ( f ( & x) ) { Some ( x) } else { None } ,
167
167
None => None
@@ -170,10 +170,16 @@ impl<T> Option<T> {
170
170
171
171
/// Maps a `some` value from one type to another by reference
172
172
#[ inline]
173
- pub fn map < ' a , U > ( & self , f : & fn ( & ' a T ) -> U ) -> Option < U > {
173
+ pub fn map < ' a , U > ( & ' a self , f : & fn ( & ' a T ) -> U ) -> Option < U > {
174
174
match * self { Some ( ref x) => Some ( f ( x) ) , None => None }
175
175
}
176
176
177
+ /// Maps a `some` value from one type to another by a mutable reference
178
+ #[ inline]
179
+ pub fn map_mut < ' a , U > ( & ' a mut self , f : & fn ( & ' a mut T ) -> U ) -> Option < U > {
180
+ match * self { Some ( ref mut x) => Some ( f ( x) ) , None => None }
181
+ }
182
+
177
183
/// As `map`, but consumes the option and gives `f` ownership to avoid
178
184
/// copying.
179
185
#[ inline]
You can’t perform that action at this time.
0 commit comments