From 35b16e545b4fce299edbc00c9a9754179fa51634 Mon Sep 17 00:00:00 2001 From: Laurenz Date: Sat, 17 Dec 2022 16:24:29 +0100 Subject: Document parameters in comment --- src/syntax/ast.rs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'src/syntax') diff --git a/src/syntax/ast.rs b/src/syntax/ast.rs index 56d4415e..abbca5ec 100644 --- a/src/syntax/ast.rs +++ b/src/syntax/ast.rs @@ -295,7 +295,7 @@ impl Raw { self.get().lang.as_ref() } - /// Whether the raw block is block-level. + /// Whether the raw text should be displayed in a separate block. pub fn block(&self) -> bool { self.get().block } @@ -425,8 +425,8 @@ impl Math { self.0.children().filter_map(SyntaxNode::cast) } - /// Whether this is a display-level math formula. - pub fn display(&self) -> bool { + /// Whether the formula should be displayed as a separate block. + pub fn block(&self) -> bool { matches!(self.children().next(), Some(MathNode::Space(_))) && matches!(self.children().last(), Some(MathNode::Space(_))) } @@ -564,8 +564,13 @@ node! { impl AlignPoint { /// The number of ampersands. - pub fn count(&self) -> usize { - self.0.children().filter(|n| n.kind() == &SyntaxKind::Amp).count() + pub fn count(&self) -> NonZeroUsize { + self.0 + .children() + .filter(|n| n.kind() == &SyntaxKind::Amp) + .count() + .try_into() + .expect("alignment point is missing ampersand sign") } } -- cgit v1.2.3