| David Tolnay | fcd8f46 | 2020-08-29 12:13:09 -0700 | [diff] [blame^] | 1 | use syn::parse::{Parse, ParseStream, Result}; |
| 2 | use syn::{Attribute, Item}; | ||||
| 3 | |||||
| 4 | pub struct File { | ||||
| 5 | pub attrs: Vec<Attribute>, | ||||
| 6 | pub items: Vec<Item>, | ||||
| 7 | } | ||||
| 8 | |||||
| 9 | impl Parse for File { | ||||
| 10 | fn parse(input: ParseStream) -> Result<Self> { | ||||
| 11 | let attrs = input.call(Attribute::parse_inner)?; | ||||
| 12 | |||||
| 13 | let mut items = Vec::new(); | ||||
| 14 | while !input.is_empty() { | ||||
| 15 | items.push(input.parse()?); | ||||
| 16 | } | ||||
| 17 | |||||
| 18 | Ok(File { attrs, items }) | ||||
| 19 | } | ||||
| 20 | } | ||||