Skip to content

Commit b4ecbe9

Browse files
committed
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]
1 parent 2b2d1e1 commit b4ecbe9

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/libstd/rt/task.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ impl Task {
109109
/// This function is *not* meant to be abused as a "try/catch" block. This
110110
/// is meant to be used at the absolute boundaries of a task's lifetime, and
111111
/// only for that purpose.
112-
pub fn run(~self, f: ||) -> ~Task {
112+
pub fn run(~self, mut f: ||) -> ~Task {
113113
// Need to put ourselves into TLS, but also need access to the unwinder.
114114
// Unsafely get a handle to the task so we can continue to use it after
115115
// putting it in tls (so we can invoke the unwinder).

src/libstd/unstable/finally.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,19 +35,19 @@ use ops::Drop;
3535
#[cfg(test)] use task::failing;
3636

3737
pub trait Finally<T> {
38-
fn finally(&self, dtor: ||) -> T;
38+
fn finally(&mut self, dtor: ||) -> T;
3939
}
4040

4141
impl<'a,T> Finally<T> for ||: 'a -> T {
42-
fn finally(&self, dtor: ||) -> T {
43-
try_finally(&mut (), (),
44-
|_, _| (*self)(),
42+
fn finally(&mut self, dtor: ||) -> T {
43+
try_finally(&mut (), self,
44+
|_, f| (*f)(),
4545
|_| dtor())
4646
}
4747
}
4848

4949
impl<T> Finally<T> for fn() -> T {
50-
fn finally(&self, dtor: ||) -> T {
50+
fn finally(&mut self, dtor: ||) -> T {
5151
try_finally(&mut (), (),
5252
|_, _| (*self)(),
5353
|_| dtor())

0 commit comments

Comments
 (0)