director_core/
macros.rs

1/// Indicates that the toggle is off.
2///
3/// Do not use
4/// ```ignore
5/// director::off!(state: Self, ..)
6/// ```
7/// This must be a dead lock.
8#[macro_export]
9macro_rules! off {
10    (state: $state:expr, $(|)? $( $pattern:pat_param )|+ $( if $guard: expr )? $(,)?) => {
11            match director::___::paste! { $state ::lock() }.get_option() {
12                $( $pattern )|+ $( if $guard )? => false,
13                _ => true
14            }
15
16    };
17    ($expression:expr, $(|)? $( $pattern:pat_param )|+ $( if $guard: expr )? $(,)?) => {
18        !matches!($expression, $( $pattern )|+ $( if $guard )?)
19    };
20}
21
22/// Indicates that the toggle is on.
23///
24/// Do not use
25/// ```ignore
26/// director::on!(state: Self, ..)
27/// ```
28/// This must be a dead lock.
29#[macro_export]
30macro_rules! on {
31    (state:$state:expr, $(|)? $( $pattern:pat_param )|+ $( if $guard: expr )? $(,)?) => {
32        match director::___::paste! { $state ::lock() }.get_option() {
33            $( $pattern )|+ $( if $guard )? => true,
34            _ => false
35        }
36
37    };
38    ($expression:expr, $(|)? $( $pattern:pat_param )|+ $( if $guard: expr )? $(,)?) => {
39        matches!($expression, $( $pattern )|+ $( if $guard )?)
40    };
41}