1
Fork 0

libstd: Get rid of move.

This commit is contained in:
Luqman Aden 2013-02-15 02:30:30 -05:00 committed by Luqman Aden
parent 9727008ed0
commit 4cf51c2531
31 changed files with 357 additions and 363 deletions

View file

@ -21,7 +21,7 @@ pub struct Cell<T> {
/// Creates a new full cell with the given value.
pub fn Cell<T>(value: T) -> Cell<T> {
Cell { value: Some(move value) }
Cell { value: Some(value) }
}
pub pure fn empty_cell<T>() -> Cell<T> {
@ -37,7 +37,7 @@ impl<T> Cell<T> {
let mut value = None;
value <-> self.value;
return option::unwrap(move value);
return option::unwrap(value);
}
/// Returns the value, failing if the cell is full.
@ -45,7 +45,7 @@ impl<T> Cell<T> {
if !self.is_empty() {
fail!(~"attempt to put a value back into a full cell");
}
self.value = Some(move value);
self.value = Some(value);
}
/// Returns true if the cell is empty and false if the cell is full.
@ -57,8 +57,8 @@ impl<T> Cell<T> {
fn with_ref<R>(op: fn(v: &T) -> R) -> R {
let v = self.take();
let r = op(&v);
self.put_back(move v);
move r
self.put_back(v);
r
}
}
@ -69,7 +69,7 @@ fn test_basic() {
let value = value_cell.take();
assert value == ~10;
assert value_cell.is_empty();
value_cell.put_back(move value);
value_cell.put_back(value);
assert !value_cell.is_empty();
}