David Tolnay | 35161ff | 2016-09-03 11:33:15 -0700 | [diff] [blame] | 1 | Nom parser for Rust items |
| 2 | ========================= |
| 3 | |
| 4 | Parse 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 Tolnay | 19229c0 | 2016-09-07 08:23:25 -0700 | [diff] [blame^] | 9 | syn = "0.4" |
David Tolnay | 35161ff | 2016-09-03 11:33:15 -0700 | [diff] [blame] | 10 | ``` |
| 11 | |
| 12 | ```rust |
| 13 | extern crate item; |
| 14 | |
| 15 | let raw = " |
David Tolnay | 99ef8c9 | 2016-09-04 11:31:37 -0700 | [diff] [blame] | 16 | #[derive(Debug, Clone, Eq, PartialEq)] |
David Tolnay | 35161ff | 2016-09-03 11:33:15 -0700 | [diff] [blame] | 17 | pub struct Item { |
| 18 | pub ident: Ident, |
David Tolnay | 99ef8c9 | 2016-09-04 11:31:37 -0700 | [diff] [blame] | 19 | pub vis: Visibility, |
David Tolnay | 35161ff | 2016-09-03 11:33:15 -0700 | [diff] [blame] | 20 | pub attrs: Vec<Attribute>, |
David Tolnay | 99ef8c9 | 2016-09-04 11:31:37 -0700 | [diff] [blame] | 21 | pub generics: Generics, |
| 22 | pub body: Body, |
David Tolnay | 35161ff | 2016-09-03 11:33:15 -0700 | [diff] [blame] | 23 | } |
| 24 | "; |
| 25 | |
David Tolnay | 62a8b69 | 2016-09-07 08:18:21 -0700 | [diff] [blame] | 26 | let ast = syn::parse_item(raw); |
David Tolnay | 35161ff | 2016-09-03 11:33:15 -0700 | [diff] [blame] | 27 | ``` |
| 28 | |
| 29 | ## License |
| 30 | |
| 31 | Licensed 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 | |
| 36 | at your option. |
| 37 | |
| 38 | ### Contribution |
| 39 | |
| 40 | Unless you explicitly state otherwise, any contribution intentionally submitted |
| 41 | for inclusion in this crate by you, as defined in the Apache-2.0 license, shall |
| 42 | be dual licensed as above, without any additional terms or conditions. |