aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_syntax')
-rw-r--r--crates/ra_syntax/src/yellow/syntax_text.rs18
1 files changed, 18 insertions, 0 deletions
diff --git a/crates/ra_syntax/src/yellow/syntax_text.rs b/crates/ra_syntax/src/yellow/syntax_text.rs
index 783dca214..279a83b61 100644
--- a/crates/ra_syntax/src/yellow/syntax_text.rs
+++ b/crates/ra_syntax/src/yellow/syntax_text.rs
@@ -125,3 +125,21 @@ impl From<SyntaxText<'_>> for String {
125 text.to_string() 125 text.to_string()
126 } 126 }
127} 127}
128
129impl PartialEq<str> for SyntaxText<'_> {
130 fn eq(&self, mut rhs: &str) -> bool {
131 for chunk in self.chunks() {
132 if !rhs.starts_with(chunk) {
133 return false;
134 }
135 rhs = &rhs[chunk.len()..];
136 }
137 rhs.is_empty()
138 }
139}
140
141impl PartialEq<&'_ str> for SyntaxText<'_> {
142 fn eq(&self, rhs: &&str) -> bool {
143 self == *rhs
144 }
145}