Dyn type
This commit is contained in:
@@ -26,6 +26,7 @@ pub enum TypePostfix {
|
||||
RefMut,
|
||||
RefLifetime(Identifier),
|
||||
RefMutLifetime(Identifier),
|
||||
Dyn,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
|
||||
@@ -85,8 +85,12 @@ ref_type = {
|
||||
mutable? ~ lifetime? ~ "*"
|
||||
}
|
||||
|
||||
dyn_type = {
|
||||
"dyn"
|
||||
}
|
||||
|
||||
type_expr = {
|
||||
(path_type | tuple_type) ~ ref_type*
|
||||
(path_type | tuple_type) ~ (ref_type | dyn_type)*
|
||||
}
|
||||
|
||||
lifetime = {
|
||||
|
||||
@@ -36,6 +36,8 @@ impl<'a> TryFrom<pest::iterators::Pair<'a, Rule>> for TypePostfix {
|
||||
})
|
||||
}
|
||||
|
||||
Rule::dyn_type => Ok(TypePostfix::Dyn),
|
||||
|
||||
_ => AstError::bug_unimplemented(pair),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -828,6 +828,7 @@ impl GetRust for TypePostfix {
|
||||
TypePostfix::RefMut => format!("&mut "),
|
||||
TypePostfix::RefLifetime(lifetime) => format!("&'{} ", lifetime.get_rust()),
|
||||
TypePostfix::RefMutLifetime(lifetime) => format!("&'{} mut ", lifetime.get_rust()),
|
||||
TypePostfix::Dyn => format!("dyn "),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user