rust/tests/ui/rfcs/rfc-2497-if-let-chains/auxiliary/macro-in-2021.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

27 lines
566 B
Rust
Raw Normal View History

//@ edition: 2021
#[macro_export]
macro_rules! make_if {
(($($tt:tt)*) { $body:expr } { $else:expr }) => {{
if $($tt)* {
$body
} else {
$else
}
}};
(let ($expr:expr) { $body:expr } { $else:expr }) => {{
if let None = $expr {
$body
} else {
$else
}
}};
(let ($expr:expr) let ($expr2:expr) { $body:expr } { $else:expr }) => {{
if let None = $expr && let None = $expr2 {
$body
} else {
$else
}
}};
}