blob: a0b87ad5cdb60ea246d97a1befd1bd56ec40065a [file] [log] [blame] [view]
David Tolnay35161ff2016-09-03 11:33:15 -07001Nom parser for Rust items
2=========================
3
David Tolnayac9953b2016-09-07 08:37:12 -07004[![Build Status](https://api.travis-ci.org/dtolnay/syn.svg?branch=master)](https://travis-ci.org/dtolnay/syn)
5[![Latest Version](https://img.shields.io/crates/v/syn.svg)](https://crates.io/crates/syn)
David Tolnay50e62202016-09-12 09:49:49 -07006[![Rust Documentation](https://img.shields.io/badge/api-rustdoc-blue.svg)](https://dtolnay.github.io/syn/syn/)
David Tolnayac9953b2016-09-07 08:37:12 -07007
David Tolnay35161ff2016-09-03 11:33:15 -07008Parse 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 Tolnayf939f352016-09-11 18:00:09 -070011Designed 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 Tolnay35161ff2016-09-03 11:33:15 -070016```toml
17[dependencies]
David Tolnay7b3973e2016-09-11 17:46:52 -070018syn = "0.5"
David Tolnay35161ff2016-09-03 11:33:15 -070019```
20
21```rust
David Tolnaya0976082016-09-07 08:24:28 -070022extern crate syn;
David Tolnay35161ff2016-09-03 11:33:15 -070023
24let raw = "
David Tolnay99ef8c92016-09-04 11:31:37 -070025 #[derive(Debug, Clone, Eq, PartialEq)]
David Tolnay35161ff2016-09-03 11:33:15 -070026 pub struct Item {
27 pub ident: Ident,
David Tolnay99ef8c92016-09-04 11:31:37 -070028 pub vis: Visibility,
David Tolnay35161ff2016-09-03 11:33:15 -070029 pub attrs: Vec<Attribute>,
David Tolnay99ef8c92016-09-04 11:31:37 -070030 pub generics: Generics,
31 pub body: Body,
David Tolnay35161ff2016-09-03 11:33:15 -070032 }
33";
34
David Tolnayb0a2c3a2016-09-11 17:48:11 -070035let ast = syn::parse_item(raw).unwrap();
David Tolnay35161ff2016-09-03 11:33:15 -070036```
37
38## License
39
40Licensed 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
45at your option.
46
47### Contribution
48
49Unless you explicitly state otherwise, any contribution intentionally submitted
50for inclusion in this crate by you, as defined in the Apache-2.0 license, shall
51be dual licensed as above, without any additional terms or conditions.