Skip to content

Commit 6113508

Browse files
committed
libstd: Remove two uses of Cell.
1 parent 89e1db3 commit 6113508

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

src/libstd/rt/deque.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,10 +163,9 @@ impl<T: Send> BufferPool<T> {
163163

164164
fn free(&mut self, buf: ~Buffer<T>) {
165165
unsafe {
166-
use cell::Cell;
167-
let buf = Cell::new(buf);
166+
let mut buf = Some(buf);
168167
self.pool.with(|pool| {
169-
let buf = buf.take();
168+
let buf = buf.take_unwrap();
170169
match pool.iter().position(|v| v.size() > buf.size()) {
171170
Some(i) => pool.insert(i, buf),
172171
None => pool.push(buf),

src/libstd/rt/task.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ use prelude::*;
1919

2020
use borrow;
2121
use cast::transmute;
22-
use cell::Cell;
2322
use cleanup;
2423
use libc::{c_void, uintptr_t, c_char, size_t};
2524
use local_data;
@@ -427,7 +426,6 @@ impl Coroutine {
427426
}
428427

429428
fn build_start_wrapper(start: proc()) -> proc() {
430-
let start_cell = Cell::new(start);
431429
let wrapper: proc() = proc() {
432430
// First code after swap to this new context. Run our
433431
// cleanup job.
@@ -446,6 +444,7 @@ impl Coroutine {
446444
// need to unsafe_borrow.
447445
let task: *mut Task = Local::unsafe_borrow();
448446

447+
let mut start_cell = Some(start);
449448
(*task).run(|| {
450449
// N.B. Removing `start` from the start wrapper
451450
// closure by emptying a cell is critical for
@@ -457,7 +456,7 @@ impl Coroutine {
457456
// be in task context. By moving `start` out of
458457
// the closure, all the user code goes our of
459458
// scope while the task is still running.
460-
let start = start_cell.take();
459+
let start = start_cell.take_unwrap();
461460
start();
462461
});
463462
}

0 commit comments

Comments
 (0)