about summary refs log tree commit diff
diff options
context:
space:
mode:
authorTobias Bucher <tobiasbucher5991@gmail.com>2014-11-20 11:20:10 +0100
committerTobias Bucher <tobiasbucher5991@gmail.com>2014-11-20 12:28:32 +0100
commitf9f5c03026ebd2c5ee6f0cba3878c08d157da9cb (patch)
tree4980623531f02bcd321a4b5350548c7de8373fbe
parentdd5ce5ae2f254cc42763518909f6e7c486d9502a (diff)
downloadrust-f9f5c03026ebd2c5ee6f0cba3878c08d157da9cb.tar.gz
rust-f9f5c03026ebd2c5ee6f0cba3878c08d157da9cb.zip
Add comment on why `RefCell::unwrap` is safe
-rw-r--r--src/libcore/cell.rs3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/libcore/cell.rs b/src/libcore/cell.rs
index 0b7389b2019..c4d0bec83ea 100644
--- a/src/libcore/cell.rs
+++ b/src/libcore/cell.rs
@@ -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()}
     }