Skip to content

Instantly share code, notes, and snippets.

@killercup
Created January 31, 2017 17:08
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 killercup/79183df0a0cf19879c21ac62b3f0a2c2 to your computer and use it in GitHub Desktop.
Save killercup/79183df0a0cf19879c21ac62b3f0a2c2 to your computer and use it in GitHub Desktop.
macro_rules! externs {
( $name:ident with macros, $($rest:tt)* ) => {
externs!($x with macros);
externs!($($rest)*);
};
( $name:ident, $($rest:tt)* ) => {
externs!($name);
externs!($($rest)*);
};
( $name:ident with macros ) => {
#[macro_use] extern crate $name;
};
( $name:ident ) => {
extern crate $name;
};
() => {}
}
externs![rocket, rocket_contrib, serde_json with macros];
// other test cases:
// externs!{ serde_json with macros }
// externs!{ rocket, rocket_contrib, }
// externs!{ rocket }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment