Skip to content

Commit 1597cec

Browse files
committed
Documentation
1 parent 334aa3d commit 1597cec

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

ui_test/src/comments.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,9 @@ impl Comments {
218218
self.env_vars.push((k.to_string(), v.to_string()));
219219
},
220220
"normalize-stderr-test" => {
221+
/// Parses a string literal. `s` has to start with `"`; everything until the next `"` is
222+
/// returned in the first component. `\` can be used to escape arbitrary character.
223+
/// Second return component is the rest of the string with leading whitespace removed.
221224
fn parse_str(s: &str) -> Result<(&str, &str)> {
222225
let mut chars = s.char_indices();
223226
match chars.next().ok_or_else(|| eyre!("missing arguments"))?.1 {
@@ -226,6 +229,7 @@ impl Comments {
226229
let mut escaped = false;
227230
for (i, c) in chars {
228231
if escaped {
232+
// Accept any character as literal after a `\`.
229233
escaped = false;
230234
} else if c == '"' {
231235
return Ok((&s[..(i - 1)], s[i..].trim_start()));

0 commit comments

Comments
 (0)