exterior mutability -> inherited mutability, another useful link, warn about transmute
[rust-101.git] / src / part12.rs
index 40d9ad52a0a1f7f0648f64239c2f8adb65bada10..58afd8da09d183a7649ab12f7697abdc2eb7df7d 100644 (file)
@@ -9,6 +9,7 @@ use std::cell::{Cell, RefCell};
 //@ (There's not even an automatic derivation happening for the cases where it would be possible.)
 //@ This restriction propagates up to `Callbacks` itself. What could we do about this?
 
+//@ ## `Rc`
 //@ The solution is to find some way of cloning `Callbacks` without cloning the environments. This can be achieved with
 //@ `Rc<T>`, a *reference-counted* pointer. This is is another example of a smart pointer. You can `clone` an `Rc` as often
 //@ as you want, that doesn't affect the data it contains. It only creates more references to the same data. Once all the
@@ -63,7 +64,7 @@ pub fn main() {
 //@ `set`, which overrides the content, only needs a *shared borrow* of the cell. The phenomenon of a type that permits mutation through
 //@ shared borrows (i.e., mutation despite the possibility of aliasing) is called *interior mutability*. You can think
 //@ of `set` changing only the *contents* of the cell, not its *identity*. In contrast, the kind of mutation we saw so far was
-//@ about replacing one piece of data by something else of the same type. This is called *exterior mutability*. <br/>
+//@ about replacing one piece of data by something else of the same type. This is called *inherited mutability*. <br/>
 //@ Notice that it is impossible to *borrow* the contents of the cell, and that is actually the key to why this is safe.
 
 // So, let us put our counter in a `Cell`, and replicate the example from the previous part.