Add ASTNode::position().

This commit is contained in:
Stephen Chung
2021-09-03 20:47:45 +08:00
parent cbe08fb64e
commit 6a2c9f0293
2 changed files with 11 additions and 0 deletions

View File

@@ -875,6 +875,16 @@ impl<'a> From<&'a Expr> for ASTNode<'a> {
}
}
impl ASTNode<'_> {
/// Get the [`Position`] of this [`ASTNode`].
pub const fn position(&self) -> Position {
match self {
ASTNode::Stmt(stmt) => stmt.position(),
ASTNode::Expr(expr) => expr.position(),
}
}
}
/// _(internals)_ A statements block.
/// Exported under the `internals` feature only.
///