From 6df57a7d680463dfb6927b4407ee2329f9288522 Mon Sep 17 00:00:00 2001 From: Geoffry Song Date: Fri, 26 Oct 2018 01:21:34 -0700 Subject: [PATCH] Slight copy-editing for `std::cell::Cell` docs Hopefully this is a bit more precise and also more correct English. --- src/libcore/cell.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/libcore/cell.rs b/src/libcore/cell.rs index ec7d366c3f5ce..689cf319bd750 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` allows to use mutable field inside -/// immutable struct (which is also called 'interior mutability'). +/// In this example, you can see that `Cell` 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); /// ```