diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2019-07-20 14:52:33 +0100 |
---|---|---|
committer | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2019-07-20 14:52:33 +0100 |
commit | 3983ccca4ac46bb7b206a5b373b10c9822280931 (patch) | |
tree | e72c3798558b7b0494990d1c994ebd9c0f3c03f3 /crates/ra_syntax/src | |
parent | dac6adbef90286f053f034eace9df65d6a19c0ff (diff) | |
parent | f6bcc2d7459a3e10090391a6f9b9a2789e9cab55 (diff) |
Merge #1566
1566: align SyntaxText API with upstream r=matklad a=matklad
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_syntax/src')
-rw-r--r-- | crates/ra_syntax/src/syntax_text.rs | 16 |
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 | ||
159 | impl fmt::Display for SyntaxText { | 149 | impl 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 | ||