diff options
| author | Laurenz <laurmaedje@gmail.com> | 2021-11-15 16:59:49 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2021-11-15 17:06:43 +0100 |
| commit | 63c274e7f6aa3a8c3f43abb91935ec924a186f73 (patch) | |
| tree | 193777ff773c6b547c6ef828ddf9750694fae7bc /src/syntax | |
| parent | 8a38899c98b4f9829b2d1f21c8fee66d254d20c6 (diff) | |
Make clippy happier and remove `Str`
Diffstat (limited to 'src/syntax')
| -rw-r--r-- | src/syntax/ast.rs | 8 | ||||
| -rw-r--r-- | src/syntax/mod.rs | 4 | ||||
| -rw-r--r-- | src/syntax/span.rs | 5 |
3 files changed, 11 insertions, 6 deletions
diff --git a/src/syntax/ast.rs b/src/syntax/ast.rs index 288c749a..0849dd58 100644 --- a/src/syntax/ast.rs +++ b/src/syntax/ast.rs @@ -65,9 +65,9 @@ impl Markup { NodeKind::Emph => Some(MarkupNode::Emph), NodeKind::Text(s) => Some(MarkupNode::Text(s.clone())), NodeKind::UnicodeEscape(c) => Some(MarkupNode::Text((*c).into())), - NodeKind::EnDash => Some(MarkupNode::Text("\u{2013}".into())), - NodeKind::EmDash => Some(MarkupNode::Text("\u{2014}".into())), - NodeKind::NonBreakingSpace => Some(MarkupNode::Text("\u{00A0}".into())), + NodeKind::EnDash => Some(MarkupNode::Text('\u{2013}'.into())), + NodeKind::EmDash => Some(MarkupNode::Text('\u{2014}'.into())), + NodeKind::NonBreakingSpace => Some(MarkupNode::Text('\u{00A0}'.into())), NodeKind::Math(math) => Some(MarkupNode::Math(math.as_ref().clone())), NodeKind::Raw(raw) => Some(MarkupNode::Raw(raw.as_ref().clone())), NodeKind::Heading => node.cast().map(MarkupNode::Heading), @@ -175,7 +175,7 @@ impl EnumNode { self.0 .children() .find_map(|node| match node.kind() { - NodeKind::EnumNumbering(num) => Some(num.clone()), + NodeKind::EnumNumbering(num) => Some(*num), _ => None, }) .expect("enum node is missing number") diff --git a/src/syntax/mod.rs b/src/syntax/mod.rs index ca6ed243..6f04cdc9 100644 --- a/src/syntax/mod.rs +++ b/src/syntax/mod.rs @@ -30,7 +30,7 @@ impl Green { fn data(&self) -> &GreenData { match self { Green::Node(n) => &n.data, - Green::Token(t) => &t, + Green::Token(t) => t, } } @@ -55,7 +55,7 @@ impl Green { /// The node's children. pub fn children(&self) -> &[Green] { match self { - Green::Node(n) => &n.children(), + Green::Node(n) => n.children(), Green::Token(_) => &[], } } diff --git a/src/syntax/span.rs b/src/syntax/span.rs index 47d96589..4d5b8819 100644 --- a/src/syntax/span.rs +++ b/src/syntax/span.rs @@ -88,6 +88,11 @@ impl Span { Self { end, ..self } } + /// Whether the span is a single point. + pub fn is_empty(self) -> bool { + self.start == self.end + } + /// The byte length of the spanned region. pub fn len(self) -> usize { self.end - self.start |
