Skip to content

Commit ac9d5ec

Browse files
authored
Rollup merge of rust-lang#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.
2 parents ddd4b19 + 6df57a7 commit ac9d5ec

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/libcore/cell.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -207,8 +207,8 @@ use ptr;
207207
///
208208
/// # Examples
209209
///
210-
/// Here you can see how using `Cell<T>` allows to use mutable field inside
211-
/// immutable struct (which is also called 'interior mutability').
210+
/// In this example, you can see that `Cell<T>` enables mutation inside an
211+
/// immutable struct. In other words, it enables "interior mutability".
212212
///
213213
/// ```
214214
/// use std::cell::Cell;
@@ -225,10 +225,11 @@ use ptr;
225225
///
226226
/// let new_value = 100;
227227
///
228-
/// // ERROR, because my_struct is immutable
228+
/// // ERROR: `my_struct` is immutable
229229
/// // my_struct.regular_field = new_value;
230230
///
231-
/// // WORKS, although `my_struct` is immutable, field `special_field` is mutable because it is Cell
231+
/// // WORKS: although `my_struct` is immutable, `special_field` is a `Cell`,
232+
/// // which can always be mutated
232233
/// my_struct.special_field.set(new_value);
233234
/// assert_eq!(my_struct.special_field.get(), new_value);
234235
/// ```

0 commit comments

Comments
 (0)