Skip to content

Instantly share code, notes, and snippets.

Created February 21, 2018 23:39
Show Gist options
  • Save anonymous/dad7acf949f0de540e9f8aca5feefe61 to your computer and use it in GitHub Desktop.
Save anonymous/dad7acf949f0de540e9f8aca5feefe61 to your computer and use it in GitHub Desktop.

Revisions

  1. @invalid-email-address Anonymous created this gist Feb 21, 2018.
    38 changes: 38 additions & 0 deletions playground.rs
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,38 @@
    #![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() {}