blob: 3c9b23cac556002bd44bf02a9784c49007638645 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
use crate::attribute::ExtendedAttributeList;
use crate::common::{Default, Identifier};
use crate::types::Type;
/// Parses dictionary members
pub type DictionaryMembers<'a> = Vec<DictionaryMember<'a>>;
ast_types! {
/// Parses dictionary member `[attributes]? required? type identifier ( = default )?;`
struct DictionaryMember<'a> {
attributes: Option<ExtendedAttributeList<'a>>,
required: Option<term!(required)>,
type_: Type<'a>,
identifier: Identifier<'a>,
default: Option<Default<'a>>,
semi_colon: term!(;),
}
}
#[cfg(test)]
mod test {
use super::*;
use crate::Parse;
test!(should_parse_dictionary_member { "required long num = 5;" =>
"";
DictionaryMember;
attributes.is_none();
required.is_some();
identifier.0 == "num";
default.is_some();
});
}
|