orengine/sync/onces/
state.rs1#[derive(Eq, PartialEq, Copy, Clone, Debug)]
8pub enum OnceState {
9 NotCalled = 0,
10 Called = 1,
11}
12
13impl OnceState {
14 pub const fn not_called() -> isize {
16 0
17 }
18
19 pub const fn called() -> isize {
21 1
22 }
23}
24
25impl From<OnceState> for isize {
26 fn from(state: OnceState) -> Self {
27 state as Self
28 }
29}
30
31impl TryFrom<isize> for OnceState {
32 type Error = ();
33
34 fn try_from(value: isize) -> Result<Self, Self::Error> {
35 match value {
36 0 => Ok(Self::NotCalled),
37 1 => Ok(Self::Called),
38 _ => Err(()),
39 }
40 }
41}