This commit is contained in:
parent
0a82816272
commit
d5402134ba
@ -9,20 +9,19 @@ pub struct TypeParser;
|
||||
|
||||
fn parse_type_array(pair: Pair<Rule>) -> Result<Vec<Box<Type>>> {
|
||||
let mut inner_rules = pair.into_inner();
|
||||
let types = inner_rules.map( |pair| parse_type_object(pair).unwrap_or_default().into()).collect();
|
||||
let types = inner_rules
|
||||
.map(|pair| parse_type_object(pair).unwrap_or_default().into())
|
||||
.collect();
|
||||
Ok(types)
|
||||
}
|
||||
|
||||
fn parse_type_object(pair: Pair<Rule>) -> Result<Type> {
|
||||
// verify that it's a type object ?
|
||||
let mut inner_rules = pair.into_inner();
|
||||
let repr = inner_rules
|
||||
.next()
|
||||
.expect("Malformed parsing")
|
||||
.as_str();
|
||||
let repr = inner_rules.next().expect("Malformed parsing").as_str();
|
||||
let subtypes = match inner_rules.next() {
|
||||
Some(a) => parse_type_array(a)?,
|
||||
None => vec![]
|
||||
None => vec![],
|
||||
};
|
||||
Ok(Type {
|
||||
repr: repr.into(),
|
||||
|
@ -5,7 +5,6 @@ pub struct Type {
|
||||
}
|
||||
|
||||
impl Type {
|
||||
|
||||
/// A function to print a Type struct as a python String
|
||||
///
|
||||
/// # Examples
|
||||
|
Loading…
Reference in New Issue
Block a user