File tree 1 file changed +5
-4
lines changed
1 file changed +5
-4
lines changed Original file line number Diff line number Diff line change @@ -207,8 +207,8 @@ use ptr;
207
207
///
208
208
/// # Examples
209
209
///
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" .
212
212
///
213
213
/// ```
214
214
/// use std::cell::Cell;
@@ -225,10 +225,11 @@ use ptr;
225
225
///
226
226
/// let new_value = 100;
227
227
///
228
- /// // ERROR, because my_struct is immutable
228
+ /// // ERROR: ` my_struct` is immutable
229
229
/// // my_struct.regular_field = new_value;
230
230
///
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
232
233
/// my_struct.special_field.set(new_value);
233
234
/// assert_eq!(my_struct.special_field.get(), new_value);
234
235
/// ```
You can’t perform that action at this time.
0 commit comments