-
-
Save rust-play/50125650e278dc8ddcab2c00a947aef3 to your computer and use it in GitHub Desktop.
Code shared from the Rust Playground
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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