diff options
| author | bors <bors@rust-lang.org> | 2013-08-23 00:16:28 -0700 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2013-08-23 00:16:28 -0700 |
| commit | 5e5e2c71e403371ff8a5d5430e7696654214a438 (patch) | |
| tree | 25ca443f4dd0b513202ddf00a4ad53515f8b184c /src/libstd/cell.rs | |
| parent | 0688bde47f1288eec730a3e01dcbf825900db3c0 (diff) | |
| parent | 0081961c57494162d9f2d19265175af95fbdd8d7 (diff) | |
auto merge of #8677 : bblum/rust/scratch, r=alexcrichton
r anybody; there isn't anything complicated here
Diffstat (limited to 'src/libstd/cell.rs')
| -rw-r--r-- | src/libstd/cell.rs | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/libstd/cell.rs b/src/libstd/cell.rs index 5db855d5b3c..f9f5b66acb6 100644 --- a/src/libstd/cell.rs +++ b/src/libstd/cell.rs @@ -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) }; |
