use std::{ cell::{Ref, RefCell, RefMut}, rc::Rc, }; pub struct State(Rc>); impl Clone for State { fn clone(&self) -> Self { Self(self.0.clone()) } } impl State { pub fn new(x: T) -> Self { Self(Rc::new(RefCell::new(x))) } pub fn get_mut(&self) -> RefMut { self.0.borrow_mut() } pub fn get(&self) -> Ref { self.0.borrow() } }