File tree 1 file changed +4
-0
lines changed
1 file changed +4
-0
lines changed Original file line number Diff line number Diff line change @@ -218,6 +218,9 @@ impl Comments {
218
218
self . env_vars . push ( ( k. to_string ( ) , v. to_string ( ) ) ) ;
219
219
} ,
220
220
"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.
221
224
fn parse_str ( s : & str ) -> Result < ( & str , & str ) > {
222
225
let mut chars = s. char_indices ( ) ;
223
226
match chars. next ( ) . ok_or_else ( || eyre ! ( "missing arguments" ) ) ?. 1 {
@@ -226,6 +229,7 @@ impl Comments {
226
229
let mut escaped = false ;
227
230
for ( i, c) in chars {
228
231
if escaped {
232
+ // Accept any character as literal after a `\`.
229
233
escaped = false ;
230
234
} else if c == '"' {
231
235
return Ok ( ( & s[ ..( i - 1 ) ] , s[ i..] . trim_start ( ) ) ) ;
You can’t perform that action at this time.
0 commit comments