diff options
Diffstat (limited to 'crates/typst-syntax')
| -rw-r--r-- | crates/typst-syntax/src/ast.rs | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/crates/typst-syntax/src/ast.rs b/crates/typst-syntax/src/ast.rs index e1741403..0df3d6d3 100644 --- a/crates/typst-syntax/src/ast.rs +++ b/crates/typst-syntax/src/ast.rs @@ -42,7 +42,7 @@ macro_rules! node { impl<'a> AstNode<'a> for $name<'a> { #[inline] fn from_untyped(node: &'a SyntaxNode) -> Option<Self> { - if matches!(node.kind(), SyntaxKind::$name) { + if node.kind() == SyntaxKind::$name { Some(Self(node)) } else { Option::None @@ -1440,6 +1440,18 @@ impl BinOp { }) } + /// Whether this is an assignment operator. + pub fn is_assignment(self) -> bool { + matches!( + self, + Self::Assign + | Self::AddAssign + | Self::SubAssign + | Self::MulAssign + | Self::DivAssign + ) + } + /// The precedence of this operator. pub fn precedence(self) -> usize { match self { |
