David Tolnay | 35161ff | 2016-09-03 11:33:15 -0700 | [diff] [blame] | 1 | Nom parser for Rust items |
| 2 | ========================= |
| 3 | |
David Tolnay | ac9953b | 2016-09-07 08:37:12 -0700 | [diff] [blame] | 4 | [](https://travis-ci.org/dtolnay/syn) |
| 5 | [](https://crates.io/crates/syn) |
David Tolnay | 50e6220 | 2016-09-12 09:49:49 -0700 | [diff] [blame] | 6 | [](https://dtolnay.github.io/syn/syn/) |
David Tolnay | ac9953b | 2016-09-07 08:37:12 -0700 | [diff] [blame] | 7 | |
David Tolnay | 35161ff | 2016-09-03 11:33:15 -0700 | [diff] [blame] | 8 | Parse Rust structs and enums without a Syntex dependency, intended for use with |
| 9 | [Macros 1.1](https://github.com/rust-lang/rfcs/blob/master/text/1681-macros-1.1.md). |
| 10 | |
David Tolnay | f939f35 | 2016-09-11 18:00:09 -0700 | [diff] [blame] | 11 | Designed for fast compile time. |
| 12 | |
| 13 | - Compile time for `syn` (from scratch including all dependencies): **6 seconds** |
| 14 | - Compile time for the `syntex`/`quasi`/`aster` stack: **60+ seconds** |
| 15 | |
David Tolnay | 35161ff | 2016-09-03 11:33:15 -0700 | [diff] [blame] | 16 | ```toml |
| 17 | [dependencies] |
David Tolnay | 7b3973e | 2016-09-11 17:46:52 -0700 | [diff] [blame] | 18 | syn = "0.5" |
David Tolnay | 35161ff | 2016-09-03 11:33:15 -0700 | [diff] [blame] | 19 | ``` |
| 20 | |
| 21 | ```rust |
David Tolnay | a097608 | 2016-09-07 08:24:28 -0700 | [diff] [blame] | 22 | extern crate syn; |
David Tolnay | 35161ff | 2016-09-03 11:33:15 -0700 | [diff] [blame] | 23 | |
| 24 | let raw = " |
David Tolnay | 99ef8c9 | 2016-09-04 11:31:37 -0700 | [diff] [blame] | 25 | #[derive(Debug, Clone, Eq, PartialEq)] |
David Tolnay | 35161ff | 2016-09-03 11:33:15 -0700 | [diff] [blame] | 26 | pub struct Item { |
| 27 | pub ident: Ident, |
David Tolnay | 99ef8c9 | 2016-09-04 11:31:37 -0700 | [diff] [blame] | 28 | pub vis: Visibility, |
David Tolnay | 35161ff | 2016-09-03 11:33:15 -0700 | [diff] [blame] | 29 | pub attrs: Vec<Attribute>, |
David Tolnay | 99ef8c9 | 2016-09-04 11:31:37 -0700 | [diff] [blame] | 30 | pub generics: Generics, |
| 31 | pub body: Body, |
David Tolnay | 35161ff | 2016-09-03 11:33:15 -0700 | [diff] [blame] | 32 | } |
| 33 | "; |
| 34 | |
David Tolnay | b0a2c3a | 2016-09-11 17:48:11 -0700 | [diff] [blame] | 35 | let ast = syn::parse_item(raw).unwrap(); |
David Tolnay | 35161ff | 2016-09-03 11:33:15 -0700 | [diff] [blame] | 36 | ``` |
| 37 | |
| 38 | ## License |
| 39 | |
| 40 | Licensed under either of |
| 41 | |
| 42 | * Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0) |
| 43 | * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT) |
| 44 | |
| 45 | at your option. |
| 46 | |
| 47 | ### Contribution |
| 48 | |
| 49 | Unless you explicitly state otherwise, any contribution intentionally submitted |
| 50 | for inclusion in this crate by you, as defined in the Apache-2.0 license, shall |
| 51 | be dual licensed as above, without any additional terms or conditions. |