Add HIR Expr machinery

This commit is contained in:
Florian Diebold 2019-01-05 16:32:07 +01:00
parent a6f33b4ca5
commit 136aba1cf3
9 changed files with 542 additions and 4 deletions

View file

@ -65,6 +65,14 @@ impl Path {
}
}
/// Converts an `ast::NameRef` into a single-identifier `Path`.
pub fn from_name_ref(name_ref: ast::NameRef) -> Path {
Path {
kind: PathKind::Plain,
segments: vec![name_ref.as_name()],
}
}
/// `true` is this path is a single identifier, like `foo`
pub fn is_ident(&self) -> bool {
self.kind == PathKind::Plain && self.segments.len() == 1