From f6bcc2d7459a3e10090391a6f9b9a2789e9cab55 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sat, 20 Jul 2019 16:52:11 +0300 Subject: align SyntaxText API with upstream --- crates/ra_syntax/src/syntax_text.rs | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) (limited to 'crates/ra_syntax/src/syntax_text.rs') 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 { } } - pub fn push_to(&self, buf: &mut String) { - self.for_each_chunk(|chunk| buf.push_str(chunk)) - } - - pub fn to_string(&self) -> String { - let mut buf = String::new(); - self.push_to(&mut buf); - buf - } - pub fn to_smol_string(&self) -> SmolStr { self.to_string().into() } - pub fn contains(&self, c: char) -> bool { + pub fn contains_char(&self, c: char) -> bool { self.try_for_each_chunk(|chunk| if chunk.contains(c) { Err(()) } else { Ok(()) }).is_err() } - pub fn find(&self, c: char) -> Option { + pub fn find_char(&self, c: char) -> Option { let mut acc: TextUnit = 0.into(); let res = self.try_for_each_chunk(|chunk| { if let Some(pos) = chunk.find(c) { @@ -158,7 +148,7 @@ impl fmt::Debug for SyntaxText { impl fmt::Display for SyntaxText { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - fmt::Display::fmt(&self.to_string(), f) + self.try_for_each_chunk(|chunk| fmt::Display::fmt(chunk, f)) } } -- cgit v1.2.3