Loading RustViz Engine...
Mutate Copy types without runtime borrow count overhead using std::cell::Cell.
This problem is currently in blueprint template mode. Once the concept foundation is finalized, live in-browser WebAssembly compilation and test assertion runners will be enabled here.
use std::cell::Cell;
pub struct Counter {
val: Cell<usize>,
}
impl Counter {
pub fn new() -> Self { Self { val: Cell::new(0) } }
pub fn inc(&self) { self.val.set(self.val.get() + 1); }
pub fn count(&self) -> usize { self.val.get() }
}