diff options
| author | Geoffry Song <goffrie@gmail.com> | 2018-10-26 01:21:34 -0700 |
|---|---|---|
| committer | Geoffry Song <goffrie@gmail.com> | 2018-10-26 12:09:41 -0700 |
| commit | 6df57a7d680463dfb6927b4407ee2329f9288522 (patch) | |
| tree | 5da712c79eb4fc87752943c563996091d24889d3 | |
| parent | 82239b04dc9cea1d54422c2fb223ff5321ccafdd (diff) | |
| download | rust-6df57a7d680463dfb6927b4407ee2329f9288522.tar.gz rust-6df57a7d680463dfb6927b4407ee2329f9288522.zip | |
Slight copy-editing for `std::cell::Cell` docs
Hopefully this is a bit more precise and also more correct English.
| -rw-r--r-- | src/libcore/cell.rs | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/libcore/cell.rs b/src/libcore/cell.rs index ec7d366c3f5..689cf319bd7 100644 --- a/src/libcore/cell.rs +++ b/src/libcore/cell.rs @@ -207,8 +207,8 @@ use ptr; /// /// # Examples /// -/// Here you can see how using `Cell<T>` allows to use mutable field inside -/// immutable struct (which is also called 'interior mutability'). +/// In this example, you can see that `Cell<T>` enables mutation inside an +/// immutable struct. In other words, it enables "interior mutability". /// /// ``` /// use std::cell::Cell; @@ -225,10 +225,11 @@ use ptr; /// /// let new_value = 100; /// -/// // ERROR, because my_struct is immutable +/// // ERROR: `my_struct` is immutable /// // my_struct.regular_field = new_value; /// -/// // WORKS, although `my_struct` is immutable, field `special_field` is mutable because it is Cell +/// // WORKS: although `my_struct` is immutable, `special_field` is a `Cell`, +/// // which can always be mutated /// my_struct.special_field.set(new_value); /// assert_eq!(my_struct.special_field.get(), new_value); /// ``` |
