auto merge of #19137 : tbu-/rust/pr_refcell_unsafety, r=huonw
This commit is contained in:
commit
2274996a1d
1 changed files with 3 additions and 0 deletions
|
@ -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()}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue