Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #![allow(unused)]
- struct PrintOnDrop(&'static str);
- impl Drop for PrintOnDrop {
- fn drop(&mut self) {
- println!("{}", self.0);
- }
- }
- fn main() {
- macro_rules! guard {
- ($label: expr) => {
- let _guard = PrintOnDrop($label);
- }
- }
- guard!("Declared first!");
- let _guard = PrintOnDrop("Declared second!");
- guard!("Declared third!");
- let _guard = PrintOnDrop("Declared fourth!");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement