diff --git a/src/librustc/middle/trans/_match.rs b/src/librustc/middle/trans/_match.rs index 9668f1ec46e3d..88e9adfba0c44 100644 --- a/src/librustc/middle/trans/_match.rs +++ b/src/librustc/middle/trans/_match.rs @@ -1155,11 +1155,11 @@ fn store_non_ref_bindings(bcx: @mut Block, let datum = Datum {val: llval, ty: binding_info.ty, mode: ByRef(ZeroMem)}; bcx = datum.store_to(bcx, INIT, lldest); - do opt_temp_cleanups.mutate |temp_cleanups| { + opt_temp_cleanups.mutate(|temp_cleanups| { add_clean_temp_mem(bcx, lldest, binding_info.ty); temp_cleanups.push(lldest); temp_cleanups - } + }); } TrByRef => {} } diff --git a/src/libstd/option.rs b/src/libstd/option.rs index 6e4880550ebb4..7a184a549506a 100644 --- a/src/libstd/option.rs +++ b/src/libstd/option.rs @@ -237,19 +237,25 @@ impl Option { self.take().map_consume_default(def, blk) } - /// Apply a function to the contained value or do nothing - pub fn mutate(&mut self, f: &fn(T) -> T) { + /// Apply a function to the contained value and return true, or return false + pub fn mutate(&mut self, f: &fn(T) -> T) -> bool { if self.is_some() { *self = Some(f(self.take_unwrap())); + return true; + } else { + return false; } } - /// Apply a function to the contained value or set it to a default - pub fn mutate_default(&mut self, def: T, f: &fn(T) -> T) { + /// Apply a function to the contained value and return true, + /// or set it to a default and return false + pub fn mutate_default(&mut self, def: T, f: &fn(T) -> T) -> bool { if self.is_some() { *self = Some(f(self.take_unwrap())); + return true; } else { *self = Some(def); + return false; } }