1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
use syn::synom::Synom;
use syn::{Attribute, Ident, Visibility};

/// Creates a new struct: `mod Foo;`.
#[allow(missing_docs)]
pub struct NewMod {
  pub attrs: Vec<Attribute>,
  pub vis: Visibility,
  pub ident: Ident,
}

impl Synom for NewMod {
  named!(parse -> Self, do_parse!(
    attrs: many0!(Attribute::parse_outer) >>
    vis: syn!(Visibility) >>
    keyword!(mod) >>
    ident: syn!(Ident) >>
    punct!(;) >>
    (NewMod { attrs, vis, ident })
  ));
}