std: Add cell to the std crate and make it build
This commit is contained in:
parent
9169a1b26a
commit
78d19d8f1b
2 changed files with 5 additions and 4 deletions
|
@ -18,10 +18,10 @@ fn empty_cell<T>() -> Cell<T> {
|
|||
impl<T> Cell<T> {
|
||||
/// Yields the value, failing if the cell is empty.
|
||||
fn take() -> T {
|
||||
let value = none;
|
||||
let mut value = none;
|
||||
value <-> self.value;
|
||||
if value.is_none() {
|
||||
fail "attempt to take an empty cell";
|
||||
fail ~"attempt to take an empty cell";
|
||||
}
|
||||
return option::unwrap(value);
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ impl<T> Cell<T> {
|
|||
/// Returns the value, failing if the cell is full.
|
||||
fn put_back(+value: T) {
|
||||
if self.value.is_none() {
|
||||
fail "attempt to put a value back into a full cell";
|
||||
fail ~"attempt to put a value back into a full cell";
|
||||
}
|
||||
self.value = some(move value);
|
||||
}
|
||||
|
@ -39,4 +39,3 @@ impl<T> Cell<T> {
|
|||
self.value.is_none()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue