We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 3c6da77 commit ac85bf3Copy full SHA for ac85bf3
src/libcore/option.rs
@@ -284,6 +284,22 @@ impl<T> Option<T> {
284
match self { None => def, Some(v) => f(v) }
285
}
286
287
+ /// Apply a function to the contained value or do nothing
288
+ fn mutate(&mut self, f: fn(T) -> T) {
289
+ if self.is_some() {
290
+ *self = Some(f(self.swap_unwrap()));
291
+ }
292
293
+
294
+ /// Apply a function to the contained value or set it to a default
295
+ fn mutate_default(&mut self, def: T, f: fn(T) -> T) {
296
297
298
+ } else {
299
+ *self = Some(def);
300
301
302
303
/// Performs an operation on the contained value by reference
304
#[inline(always)]
305
pure fn iter(&self, f: fn(x: &T)) { iter(self, f) }
0 commit comments