blob: 7ebce277ba6f277c9c3369f17b9e2da93626c43e [file] [log] [blame] [view]
David Tolnay35161ff2016-09-03 11:33:15 -07001Nom parser for Rust items
2=========================
3
4Parse Rust structs and enums without a Syntex dependency, intended for use with
5[Macros 1.1](https://github.com/rust-lang/rfcs/blob/master/text/1681-macros-1.1.md).
6
7```toml
8[dependencies]
David Tolnay19229c02016-09-07 08:23:25 -07009syn = "0.4"
David Tolnay35161ff2016-09-03 11:33:15 -070010```
11
12```rust
David Tolnaya0976082016-09-07 08:24:28 -070013extern crate syn;
David Tolnay35161ff2016-09-03 11:33:15 -070014
15let raw = "
David Tolnay99ef8c92016-09-04 11:31:37 -070016 #[derive(Debug, Clone, Eq, PartialEq)]
David Tolnay35161ff2016-09-03 11:33:15 -070017 pub struct Item {
18 pub ident: Ident,
David Tolnay99ef8c92016-09-04 11:31:37 -070019 pub vis: Visibility,
David Tolnay35161ff2016-09-03 11:33:15 -070020 pub attrs: Vec<Attribute>,
David Tolnay99ef8c92016-09-04 11:31:37 -070021 pub generics: Generics,
22 pub body: Body,
David Tolnay35161ff2016-09-03 11:33:15 -070023 }
24";
25
David Tolnay62a8b692016-09-07 08:18:21 -070026let ast = syn::parse_item(raw);
David Tolnay35161ff2016-09-03 11:33:15 -070027```
28
29## License
30
31Licensed under either of
32
33 * Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
34 * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)
35
36at your option.
37
38### Contribution
39
40Unless you explicitly state otherwise, any contribution intentionally submitted
41for inclusion in this crate by you, as defined in the Apache-2.0 license, shall
42be dual licensed as above, without any additional terms or conditions.