1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
use std::rc::Rc;
#[derive(Debug)]
pub struct State<St>(Rc<St>);
impl<St> State<St> {
pub(crate) fn new(st: St) -> Self {
State(Rc::new(st))
}
pub fn get_ref(&self) -> &St {
self.0.as_ref()
}
}
impl<St> Clone for State<St> {
#[inline]
fn clone(&self) -> Self {
Self(self.0.clone())
}
}
impl<St> std::ops::Deref for State<St> {
type Target = St;
fn deref(&self) -> &Self::Target {
self.get_ref()
}
}