1
Fork 0

auto merge of #8677 : bblum/rust/scratch, r=alexcrichton

r anybody; there isn't anything complicated here
This commit is contained in:
bors 2013-08-23 00:16:28 -07:00
commit 5e5e2c71e4
7 changed files with 110 additions and 54 deletions

View file

@ -50,6 +50,12 @@ impl<T> Cell<T> {
this.value.take_unwrap()
}
/// Yields the value if the cell is full, or `None` if it is empty.
pub fn take_opt(&self) -> Option<T> {
let this = unsafe { transmute_mut(self) };
this.value.take()
}
/// Returns the value, failing if the cell is full.
pub fn put_back(&self, value: T) {
let this = unsafe { transmute_mut(self) };