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