Skip to content

Instantly share code, notes, and snippets.

@durka
Forked from anonymous/playground.rs
Created February 21, 2018 23:39
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 durka/2d8ddad10572d3713c687c65c3cf2f4b to your computer and use it in GitHub Desktop.
Save durka/2d8ddad10572d3713c687c65c3cf2f4b to your computer and use it in GitHub Desktop.
How to get around lockstep iteration restrictions
#![feature(trace_macros)] trace_macros!(true);
macro_rules! doc_items {
(@distribute $docs:tt $($item:item)*) => {
$(doc_items!(@output $docs $item);)*
};
(@output [$($doc:expr),*] $item:item) => {
$(#[doc=$doc])*
$item
};
{
$(
$(#[doc = $doc:expr])*
{
$(
$item:item
)*
}
)+
} => {
$(doc_items!(@distribute [$($doc),*] $($item)*);)*
};
}
doc_items! {
/// A
{
struct Foo;
struct Bar;
}
/// B
{
struct Baz;
struct Quux;
}
}
fn main() {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment