I’ve been reading Cell docs a few times ending them with sentence… “maybe some other time i’ll get it…” and then i hit this
Such a simple example
use std::cell::Cell;
struct NaiveRc<'a, T: 'a> {
inner_value: &'a T,
references: Cell<usize>
}
let x = NaiveRc { inner_value: &1, references: Cell::new(1) }; // x is immutable
x.references.set(2); // it works!
x.inner_value = &2; // beep boop, x is immutable,
// you can't assign a new value to any of its fields!
What do you think about including it as example?