Add details about types with interior mutability to E0386.
Types with interior mutability like `Cell` and `RefCell` can be used to skirt the restriction on mutating mutable values inside an immutable container.
This commit is contained in:
parent
55752a4bde
commit
75c6428e1b
@ -179,6 +179,14 @@ fn main(){
|
||||
let mut y: Box<_> = Box::new(&mut x);
|
||||
**y = 2;
|
||||
```
|
||||
|
||||
It can also be fixed by using a type with interior mutability, such as `Cell` or
|
||||
`RefCell`:
|
||||
|
||||
```
|
||||
let y: Cell<_> = Cell::new(1);
|
||||
y.set(2);
|
||||
```
|
||||
"##,
|
||||
|
||||
E0387: r##"
|
||||
|
Loading…
Reference in New Issue
Block a user