diff options
| author | kennytm <kennytm@gmail.com> | 2018-11-07 18:01:45 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-11-07 18:01:45 +0800 |
| commit | ac9d5ec74e8169dfc1ae787e086a53fa1bcbc4c7 (patch) | |
| tree | e73c40d7eb251b22f3d19948d183ffab36ab3b9f /src | |
| parent | ddd4b194a0c28065a277c1f964aa931cc021b5c6 (diff) | |
| parent | 6df57a7d680463dfb6927b4407ee2329f9288522 (diff) | |
| download | rust-ac9d5ec74e8169dfc1ae787e086a53fa1bcbc4c7.tar.gz rust-ac9d5ec74e8169dfc1ae787e086a53fa1bcbc4c7.zip | |
Rollup merge of #55377 - goffrie:patch-2, r=joshtriplett
Slight copy-editing for `std::cell::Cell` docs Hopefully this is a bit more precise and also more correct English.
Diffstat (limited to 'src')
| -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); /// ``` |
