Type params gen
This commit is contained in:
+2
-1
@@ -13,7 +13,8 @@ pub struct Block(pub Vec<Statement>);
|
||||
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
pub enum TypeExpr {
|
||||
Path(StaticPath, Vec<TypeExpr>),
|
||||
Path(StaticPath),
|
||||
PathParams(StaticPath, Vec<TypeExpr>),
|
||||
Tuple(Vec<TypeExpr>),
|
||||
}
|
||||
|
||||
|
||||
+7
-1
@@ -33,8 +33,14 @@ impl From<pest::iterators::Pair<'_, Rule>> for TypeExpr {
|
||||
Rule::tuple_type => TypeExpr::Tuple(pair.into_inner().map(TypeExpr::from).collect()),
|
||||
Rule::path_type => {
|
||||
let mut inner = pair.into_inner();
|
||||
let path = StaticPath::from(inner.next().unwrap());
|
||||
let params = inner.map(TypeExpr::from).collect::<Vec<_>>();
|
||||
|
||||
TypeExpr::Path(StaticPath::from(inner.next().unwrap()), inner.map(TypeExpr::from).collect())
|
||||
if params.len() == 0 {
|
||||
TypeExpr::Path(path)
|
||||
} else {
|
||||
TypeExpr::PathParams(path, params)
|
||||
}
|
||||
}
|
||||
_ => unimplemented!("{pair:#?}"),
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user