Added ArrayExprKind,

changed the  display for fixed array types,
Added Array Enum to ra_hir/expr
This commit is contained in:
Lenard Pratt 2019-04-04 23:29:21 +01:00
parent 2d73c909fe
commit e175921932
5 changed files with 76 additions and 31 deletions

View file

@ -193,6 +193,28 @@ impl ast::BinExpr {
}
}
pub enum ArrayExprKind<'a> {
Repeat { initializer: Option<&'a ast::Expr>, repeat: Option<&'a ast::Expr> },
ElementList(AstChildren<'a, ast::Expr>),
}
impl ast::ArrayExpr {
pub fn kind(&self) -> ArrayExprKind {
if self.is_repeat() {
ArrayExprKind::Repeat {
initializer: children(self).nth(0),
repeat: children(self).nth(2),
}
} else {
ArrayExprKind::ElementList(children(self))
}
}
fn is_repeat(&self) -> bool {
self.syntax().children_with_tokens().any(|it| it.kind() == SEMI)
}
}
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub enum LiteralKind {
String,