std: Change Finally to take &mut self
As with the previous commits, the Finally trait is primarily implemented for closures, so the trait was modified from `&self` to `&mut self`. This will require that any closure variable invoked with `finally` to be stored in a mutable slot. [breaking-change]
This commit is contained in:
parent
2b2d1e14c9
commit
b4ecbe9340
2 changed files with 6 additions and 6 deletions
|
|
@ -35,19 +35,19 @@ use ops::Drop;
|
|||
#[cfg(test)] use task::failing;
|
||||
|
||||
pub trait Finally<T> {
|
||||
fn finally(&self, dtor: ||) -> T;
|
||||
fn finally(&mut self, dtor: ||) -> T;
|
||||
}
|
||||
|
||||
impl<'a,T> Finally<T> for ||: 'a -> T {
|
||||
fn finally(&self, dtor: ||) -> T {
|
||||
try_finally(&mut (), (),
|
||||
|_, _| (*self)(),
|
||||
fn finally(&mut self, dtor: ||) -> T {
|
||||
try_finally(&mut (), self,
|
||||
|_, f| (*f)(),
|
||||
|_| dtor())
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> Finally<T> for fn() -> T {
|
||||
fn finally(&self, dtor: ||) -> T {
|
||||
fn finally(&mut self, dtor: ||) -> T {
|
||||
try_finally(&mut (), (),
|
||||
|_, _| (*self)(),
|
||||
|_| dtor())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue