Skip to content

Instantly share code, notes, and snippets.

@rust-play
Created December 5, 2019 20:21
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/bca9865bb80610e5c362181ccdcf5f00 to your computer and use it in GitHub Desktop.
Save rust-play/bca9865bb80610e5c362181ccdcf5f00 to your computer and use it in GitHub Desktop.
Code shared from the Rust Playground
macro_rules! test_cases {
(@ [ :: $variant:ident :: stream :: compress ]) => {
#[test] fn a() { }
};
(@ [ :: $variant:ident :: futures :: write :: compress ]) => {
#[test] fn b() { }
};
(@ [ :: $variant:ident :: futures :: write :: decompress ]) => {
#[test] fn c() { }
};
// expansions, generating a `mod $ident { }` around each level
($variant:ident) => {
test_cases!($variant::{stream::compress, futures::write::{compress, decompress}});
};
}
test_cases!(foobar);
// mod foobar {
// mod stream {
// mod compress {
// #[test] fn a() {}
// }
// }
// mod futures {
// mod write {
// mod compress {
// #[test] fn b() {}
// }
// mod decompress {
// #[test] fn c() {}
// }
// }
// }
// }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment