Skip to content

Instantly share code, notes, and snippets.

@rust-play
Created February 4, 2023 17:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rust-play/50125650e278dc8ddcab2c00a947aef3 to your computer and use it in GitHub Desktop.
Save rust-play/50125650e278dc8ddcab2c00a947aef3 to your computer and use it in GitHub Desktop.
Code shared from the Rust Playground
macro_rules! express {
($thing:ident $( . $method:ident ( $($args:tt)* ) )*) => {{
let mut thing = $thing;
$( thing.$method($($args)*); )*
thing
}};
}
fn main() {
let a = vec![];
let b = express!(a.push(1).push(2).push(34));
println!("{:?}", b);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment