diff options
Diffstat (limited to 'crates/ra_syntax')
-rw-r--r-- | crates/ra_syntax/src/syntax_text.rs | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/crates/ra_syntax/src/syntax_text.rs b/crates/ra_syntax/src/syntax_text.rs index b013164c4..c9038cd5c 100644 --- a/crates/ra_syntax/src/syntax_text.rs +++ b/crates/ra_syntax/src/syntax_text.rs | |||
@@ -1,6 +1,6 @@ | |||
1 | use std::{fmt, ops::{self, Bound}}; | 1 | use std::{fmt, ops::{self, Bound}}; |
2 | 2 | ||
3 | use crate::{SyntaxNode, TextRange, TextUnit, SyntaxElement}; | 3 | use crate::{SmolStr, SyntaxNode, TextRange, TextUnit, SyntaxElement}; |
4 | 4 | ||
5 | #[derive(Clone)] | 5 | #[derive(Clone)] |
6 | pub struct SyntaxText<'a> { | 6 | pub struct SyntaxText<'a> { |
@@ -34,6 +34,12 @@ impl<'a> SyntaxText<'a> { | |||
34 | self.chunks().collect() | 34 | self.chunks().collect() |
35 | } | 35 | } |
36 | 36 | ||
37 | pub fn to_smol_string(&self) -> SmolStr { | ||
38 | // FIXME: use `self.chunks().collect()` here too once | ||
39 | // https://github.com/matklad/smol_str/pull/12 is merged and published | ||
40 | self.to_string().into() | ||
41 | } | ||
42 | |||
37 | pub fn contains(&self, c: char) -> bool { | 43 | pub fn contains(&self, c: char) -> bool { |
38 | self.chunks().any(|it| it.contains(c)) | 44 | self.chunks().any(|it| it.contains(c)) |
39 | } | 45 | } |