1 2 3 4 5 6 7 8 9 10 11 12 13 14
#[macro_export] macro_rules! UnsafeOnce { ($t: ty, $b: block) => {{ static mut S: Option<$t> = None; unsafe { if S.is_some() { } else { S = Some($b); } S.as_mut() } .unwrap() }}; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14
#[macro_export] macro_rules! UnsafeOnce { ($t: ty, $b: block) => {{ static mut S: Option<$t> = None; unsafe { if S.is_some() { } else { S = Some($b); } S.as_mut() } .unwrap() }}; }