File tree Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Original file line number Diff line number Diff 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/// ```
You can’t perform that action at this time.
0 commit comments