Expand description
Postfix macros on stable Rust, today.
postfix_macros! {
"hello world".println!();
42.assert_ne!(4 + 2);
val.iter()
.map(|v| v.1)
.find(|z| z.matches!(Custom::Enum(_) | Custom::EnumOther))
.dbg!()
.unwrap_or!{ return };
}The crate provides the postfix_macros! macro,
as well as some helpful macros for use in a postfix context,
for your greatest convenience.
| Rust construct | postfix replacement macro |
|---|---|
unwrap_or, unwrap_or_else | unwrap_or! |
if let with else clause | match_or! |
match with default case | match_or! |
if <bool>, bool::then | then! |
else | then_else! |
Macrosยง
- match_
or matchmacro with a default case shorthand- postfix_
macros - Proc macro to parse code containing postfix macros, to rewrite it to use traditional macro invocations.
- then
- Executes the body if the argument is
true - then_
else elseclauses for thethen!macro- unwrap_
or - Either unwraps the content passed to the macro, or executes the passed code block.