auto merge of #8677 : bblum/rust/scratch, r=alexcrichton
r anybody; there isn't anything complicated here
This commit is contained in:
commit
5e5e2c71e4
7 changed files with 110 additions and 54 deletions
|
@ -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) };
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue