scsys_core/state/traits/
state_repr.rs1use super::RawState;
6
7pub trait StateRepr {
10 type Item: RawState;
11
12 private!();
13}
14
15use crate::state::{State, StateBase};
19
20impl<Q> StateRepr for State<Q>
21where
22 Q: RawState,
23{
24 type Item = Q;
25
26 seal!();
27}
28
29impl<Q, K> StateRepr for StateBase<Q, K>
30where
31 Q: RawState,
32{
33 type Item = Q;
34
35 seal!();
36}
37
38macro_rules! impl_state_repr {
39 (@impl $($t:ident)::*<$T:ident>) => {
40 impl<$T> $crate::state::StateRepr for $($t)::*<$T>
48 where
49 $T: $crate::state::RawState,
50 {
51 type Item = $T;
52
53 seal!();
54 }
55 };
56 (
57 $(
58 $($t:ident)::*<$T:ident>
59 ),* $(,)?
60 ) => {
61 $(
62 impl_state_repr!(@impl $($t)::*<$T>);
63 )*
64 };
65}
66
67impl_state_repr! {
68 Option<Q>,
69 core::mem::MaybeUninit<Q>,
70 core::marker::PhantomData<Q>,
71}
72
73#[cfg(feature = "alloc")]
74impl_state_repr! {
75 alloc::sync::Arc<Q>,
76 alloc::boxed::Box<Q>,
77 alloc::rc::Rc<Q>,
78 alloc::vec::Vec<Q>,
79}
80
81#[cfg(feature = "std")]
82impl_state_repr! {
83 std::cell::Cell<Q>,
84 std::sync::Mutex<Q>,
85}