diff options
| author | Tymoteusz Jankowski <tymoteusz.jankowski@gmail.com> | 2017-07-24 21:45:21 +0200 |
|---|---|---|
| committer | Tymoteusz Jankowski <tymoteusz.jankowski@gmail.com> | 2017-07-24 21:45:21 +0200 |
| commit | beb072a8938db93e694435e852510b79a0909fd3 (patch) | |
| tree | 7425735a7ba21aa36efcadb1dc12182025647b62 | |
| parent | 82860753463314e6a1b94f1f97d4d9c4effc0742 (diff) | |
| download | rust-beb072a8938db93e694435e852510b79a0909fd3.tar.gz rust-beb072a8938db93e694435e852510b79a0909fd3.zip | |
empty lines
| -rw-r--r-- | src/libcore/cell.rs | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/libcore/cell.rs b/src/libcore/cell.rs index 1610e89a82d..1e7c8dfce5b 100644 --- a/src/libcore/cell.rs +++ b/src/libcore/cell.rs @@ -187,9 +187,12 @@ use ops::{Deref, DerefMut, CoerceUnsized}; use ptr; /// A mutable memory location. +/// /// # Examples +/// /// Here you can see how using `Cell<T>` allows to use mutable field inside /// immutable struct (which is also called 'interior mutability'). +/// /// ``` /// use std::cell::Cell; /// @@ -204,8 +207,10 @@ use ptr; /// }; /// /// let new_value = 100; +/// /// // ERROR, because my_struct is immutable /// // immutable.regular_field = new_value; +/// /// // WORKS, although `my_struct` is immutable, field `special_field` is mutable because it is Cell /// immutable.special_field.set(new_value); /// assert_eq!(immutable.special_field.get(), new_value); |
