scsys_core/state/impls/
impl_repr.rs1use crate::state::State;
6
7impl<'a, T> State<&'a T> {
8 pub fn cloned(&self) -> State<T>
10 where
11 T: Clone,
12 {
13 State(self.0.clone())
14 }
15 pub fn copied(&self) -> State<T>
17 where
18 T: Copy,
19 {
20 State(*self.0)
21 }
22}
23
24impl<'a, T> State<&'a mut T> {
25 pub fn cloned(&self) -> State<T>
27 where
28 T: Clone,
29 {
30 State(self.0.clone())
31 }
32 pub fn copied(&self) -> State<T>
34 where
35 T: Copy,
36 {
37 State(*self.0)
38 }
39}
40
41impl<T> State<*const T> {}
42
43impl<T> State<core::mem::MaybeUninit<T>> {
44 pub fn unit() -> State<core::mem::MaybeUninit<T>> {
46 State(core::mem::MaybeUninit::uninit())
47 }
48}
49
50impl<T> State<Option<T>> {
51 pub fn none() -> State<Option<T>> {
53 State(None)
54 }
55 pub fn some(value: T) -> State<Option<T>> {
57 State(Some(value))
58 }
59
60 pub fn is_none(&self) -> bool {
61 self.get().is_none()
62 }
63}