blob: 1248eddd941b24faf83c910a01cb68c4fa2067e2 [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)
6[![Rust Documentation](https://img.shields.io/crates/v/syn.svg?label=rustdoc)](https://dtolnay.github.io/syn/syn/)
7
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
11```toml
12[dependencies]
David Tolnay19229c02016-09-07 08:23:25 -070013syn = "0.4"
David Tolnay35161ff2016-09-03 11:33:15 -070014```
15
16```rust
David Tolnaya0976082016-09-07 08:24:28 -070017extern crate syn;
David Tolnay35161ff2016-09-03 11:33:15 -070018
19let raw = "
David Tolnay99ef8c92016-09-04 11:31:37 -070020 #[derive(Debug, Clone, Eq, PartialEq)]
David Tolnay35161ff2016-09-03 11:33:15 -070021 pub struct Item {
22 pub ident: Ident,
David Tolnay99ef8c92016-09-04 11:31:37 -070023 pub vis: Visibility,
David Tolnay35161ff2016-09-03 11:33:15 -070024 pub attrs: Vec<Attribute>,
David Tolnay99ef8c92016-09-04 11:31:37 -070025 pub generics: Generics,
26 pub body: Body,
David Tolnay35161ff2016-09-03 11:33:15 -070027 }
28";
29
David Tolnay62a8b692016-09-07 08:18:21 -070030let ast = syn::parse_item(raw);
David Tolnay35161ff2016-09-03 11:33:15 -070031```
32
33## License
34
35Licensed under either of
36
37 * Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
38 * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)
39
40at your option.
41
42### Contribution
43
44Unless you explicitly state otherwise, any contribution intentionally submitted
45for inclusion in this crate by you, as defined in the Apache-2.0 license, shall
46be dual licensed as above, without any additional terms or conditions.