auto merge of #19137 : tbu-/rust/pr_refcell_unsafety, r=huonw

This commit is contained in:
bors 2014-11-23 00:36:43 +00:00
commit 2274996a1d

View file

@ -258,6 +258,9 @@ impl<T> RefCell<T> {
/// Consumes the `RefCell`, returning the wrapped value.
#[unstable = "may be renamed, depending on global conventions"]
pub fn unwrap(self) -> T {
// Since this function takes `self` (the `RefCell`) by value, the
// compiler statically verifies that it is not currently borrowed.
// Therefore the following assertion is just a `debug_assert!`.
debug_assert!(self.borrow.get() == UNUSED);
unsafe{self.value.unwrap()}
}