k8s_openapi/mnt/build/debug/build/k8s-openapi-0d829e400799003f/out/
conditional_compilation_macros.rs

1/// This macro evaluates to its contents if the `v1_30` feature is enabled, otherwise it evaluates to nothing.
2///
3/// # Examples
4///
5/// ```rust
6/// # #[macro_use] extern crate k8s_openapi;
7/// k8s_if_1_30! {
8///     use k8s_openapi::api::core::v1 as api;
9/// }
10/// ```
11#[macro_export] macro_rules! k8s_if_1_30 { ($($tt:tt)*) => { }; }
12
13/// This macro evaluates to its contents if the `v1_30` or higher feature is enabled, otherwise it evaluates to nothing.
14#[macro_export] macro_rules! k8s_if_ge_1_30 { ($($tt:tt)*) => { $($tt)* }; }
15
16/// This macro evaluates to its contents if the `v1_30` or lower feature is enabled, otherwise it evaluates to nothing.
17#[macro_export] macro_rules! k8s_if_le_1_30 { ($($tt:tt)*) => { }; }
18
19/// This macro evaluates to its contents if the `v1_31` feature is enabled, otherwise it evaluates to nothing.
20///
21/// # Examples
22///
23/// ```rust
24/// # #[macro_use] extern crate k8s_openapi;
25/// k8s_if_1_31! {
26///     use k8s_openapi::api::core::v1 as api;
27/// }
28/// ```
29#[macro_export] macro_rules! k8s_if_1_31 { ($($tt:tt)*) => { $($tt)* }; }
30
31/// This macro evaluates to its contents if the `v1_31` or higher feature is enabled, otherwise it evaluates to nothing.
32#[macro_export] macro_rules! k8s_if_ge_1_31 { ($($tt:tt)*) => { $($tt)* }; }
33
34/// This macro evaluates to its contents if the `v1_31` or lower feature is enabled, otherwise it evaluates to nothing.
35#[macro_export] macro_rules! k8s_if_le_1_31 { ($($tt:tt)*) => { $($tt)* }; }
36
37/// This macro evaluates to its contents if the `v1_32` feature is enabled, otherwise it evaluates to nothing.
38///
39/// # Examples
40///
41/// ```rust
42/// # #[macro_use] extern crate k8s_openapi;
43/// k8s_if_1_32! {
44///     use k8s_openapi::api::core::v1 as api;
45/// }
46/// ```
47#[macro_export] macro_rules! k8s_if_1_32 { ($($tt:tt)*) => { }; }
48
49/// This macro evaluates to its contents if the `v1_32` or higher feature is enabled, otherwise it evaluates to nothing.
50#[macro_export] macro_rules! k8s_if_ge_1_32 { ($($tt:tt)*) => { }; }
51
52/// This macro evaluates to its contents if the `v1_32` or lower feature is enabled, otherwise it evaluates to nothing.
53#[macro_export] macro_rules! k8s_if_le_1_32 { ($($tt:tt)*) => { $($tt)* }; }
54
55/// This macro evaluates to its contents if the `v1_33` feature is enabled, otherwise it evaluates to nothing.
56///
57/// # Examples
58///
59/// ```rust
60/// # #[macro_use] extern crate k8s_openapi;
61/// k8s_if_1_33! {
62///     use k8s_openapi::api::core::v1 as api;
63/// }
64/// ```
65#[macro_export] macro_rules! k8s_if_1_33 { ($($tt:tt)*) => { }; }
66
67/// This macro evaluates to its contents if the `v1_33` or higher feature is enabled, otherwise it evaluates to nothing.
68#[macro_export] macro_rules! k8s_if_ge_1_33 { ($($tt:tt)*) => { }; }
69
70/// This macro evaluates to its contents if the `v1_33` or lower feature is enabled, otherwise it evaluates to nothing.
71#[macro_export] macro_rules! k8s_if_le_1_33 { ($($tt:tt)*) => { $($tt)* }; }
72
73/// A macro that emits a `match` expr with the given test expression and arms.
74/// The match arms can be annotated with the other conditional compilation macros in this crate so that they're only emitted
75/// if the predicate is true.
76#[macro_export] macro_rules! k8s_match {
77    (@inner { $test:expr } { $($arms:tt)* } { }) => {
78        match $test { $($arms)* }
79    };
80
81    (@inner { $test:expr } { $($arms:tt)* } { k8s_if_1_30!($($arm:tt)*), $($rest:tt)* }) => {
82        k8s_match!(@inner { $test } { $($arms)* } { $($rest)* })
83    };
84    (@inner { $test:expr } { $($arms:tt)* } { k8s_if_ge_1_30!($($arm:tt)*), $($rest:tt)* }) => {
85        k8s_match!(@inner { $test } { $($arms)* } { $($arm)*, $($rest)* })
86    };
87    (@inner { $test:expr } { $($arms:tt)* } { k8s_if_le_1_30!($($arm:tt)*), $($rest:tt)* }) => {
88        k8s_match!(@inner { $test } { $($arms)* } { $($rest)* })
89    };
90
91    (@inner { $test:expr } { $($arms:tt)* } { k8s_if_1_31!($($arm:tt)*), $($rest:tt)* }) => {
92        k8s_match!(@inner { $test } { $($arms)* } { $($arm)*, $($rest)* })
93    };
94    (@inner { $test:expr } { $($arms:tt)* } { k8s_if_ge_1_31!($($arm:tt)*), $($rest:tt)* }) => {
95        k8s_match!(@inner { $test } { $($arms)* } { $($arm)*, $($rest)* })
96    };
97    (@inner { $test:expr } { $($arms:tt)* } { k8s_if_le_1_31!($($arm:tt)*), $($rest:tt)* }) => {
98        k8s_match!(@inner { $test } { $($arms)* } { $($arm)*, $($rest)* })
99    };
100
101    (@inner { $test:expr } { $($arms:tt)* } { k8s_if_1_32!($($arm:tt)*), $($rest:tt)* }) => {
102        k8s_match!(@inner { $test } { $($arms)* } { $($rest)* })
103    };
104    (@inner { $test:expr } { $($arms:tt)* } { k8s_if_ge_1_32!($($arm:tt)*), $($rest:tt)* }) => {
105        k8s_match!(@inner { $test } { $($arms)* } { $($rest)* })
106    };
107    (@inner { $test:expr } { $($arms:tt)* } { k8s_if_le_1_32!($($arm:tt)*), $($rest:tt)* }) => {
108        k8s_match!(@inner { $test } { $($arms)* } { $($arm)*, $($rest)* })
109    };
110
111    (@inner { $test:expr } { $($arms:tt)* } { k8s_if_1_33!($($arm:tt)*), $($rest:tt)* }) => {
112        k8s_match!(@inner { $test } { $($arms)* } { $($rest)* })
113    };
114    (@inner { $test:expr } { $($arms:tt)* } { k8s_if_ge_1_33!($($arm:tt)*), $($rest:tt)* }) => {
115        k8s_match!(@inner { $test } { $($arms)* } { $($rest)* })
116    };
117    (@inner { $test:expr } { $($arms:tt)* } { k8s_if_le_1_33!($($arm:tt)*), $($rest:tt)* }) => {
118        k8s_match!(@inner { $test } { $($arms)* } { $($arm)*, $($rest)* })
119    };
120
121    (@inner { $test:expr } { $($arms:tt)* } { $next_pat:pat $(if $cond:expr)? => $next_expr:expr, $($rest:tt)* }) => {
122        k8s_match!(@inner { $test } { $($arms)* $next_pat $(if $cond)? => $next_expr, } { $($rest)* })
123    };
124
125    ($test:expr, { $($rest:tt)* }) => {
126        k8s_match!(@inner { $test } { } { $($rest)* })
127    };
128}