aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_syntax/src')
-rw-r--r--crates/ra_syntax/src/syntax_text.rs16
1 files changed, 3 insertions, 13 deletions
diff --git a/crates/ra_syntax/src/syntax_text.rs b/crates/ra_syntax/src/syntax_text.rs
index f8ddff48e..652cb7a1e 100644
--- a/crates/ra_syntax/src/syntax_text.rs
+++ b/crates/ra_syntax/src/syntax_text.rs
@@ -57,25 +57,15 @@ impl SyntaxText {
57 } 57 }
58 } 58 }
59 59
60 pub fn push_to(&self, buf: &mut String) {
61 self.for_each_chunk(|chunk| buf.push_str(chunk))
62 }
63
64 pub fn to_string(&self) -> String {
65 let mut buf = String::new();
66 self.push_to(&mut buf);
67 buf
68 }
69
70 pub fn to_smol_string(&self) -> SmolStr { 60 pub fn to_smol_string(&self) -> SmolStr {
71 self.to_string().into() 61 self.to_string().into()
72 } 62 }
73 63
74 pub fn contains(&self, c: char) -> bool { 64 pub fn contains_char(&self, c: char) -> bool {
75 self.try_for_each_chunk(|chunk| if chunk.contains(c) { Err(()) } else { Ok(()) }).is_err() 65 self.try_for_each_chunk(|chunk| if chunk.contains(c) { Err(()) } else { Ok(()) }).is_err()
76 } 66 }
77 67
78 pub fn find(&self, c: char) -> Option<TextUnit> { 68 pub fn find_char(&self, c: char) -> Option<TextUnit> {
79 let mut acc: TextUnit = 0.into(); 69 let mut acc: TextUnit = 0.into();
80 let res = self.try_for_each_chunk(|chunk| { 70 let res = self.try_for_each_chunk(|chunk| {
81 if let Some(pos) = chunk.find(c) { 71 if let Some(pos) = chunk.find(c) {
@@ -158,7 +148,7 @@ impl fmt::Debug for SyntaxText {
158 148
159impl fmt::Display for SyntaxText { 149impl fmt::Display for SyntaxText {
160 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { 150 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
161 fmt::Display::fmt(&self.to_string(), f) 151 self.try_for_each_chunk(|chunk| fmt::Display::fmt(chunk, f))
162 } 152 }
163} 153}
164 154