File tree Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -478,10 +478,9 @@ fn cooked_byte_string(mut input: Cursor) -> Result<Cursor, Reject> {
478
478
Err ( Reject )
479
479
}
480
480
481
- fn raw_string ( input : Cursor ) -> Result < Cursor , Reject > {
482
- let mut chars = input. char_indices ( ) ;
481
+ fn delimiter_of_raw_string ( input : Cursor ) -> PResult < & str > {
483
482
let mut n = 0 ;
484
- for ( i, ch) in & mut chars {
483
+ for ( i, ch) in input . char_indices ( ) {
485
484
match ch {
486
485
'"' => {
487
486
n = i;
@@ -495,10 +494,16 @@ fn raw_string(input: Cursor) -> Result<Cursor, Reject> {
495
494
// https://github.com/rust-lang/rust/pull/95251
496
495
return Err ( Reject ) ;
497
496
}
497
+ Ok ( ( input. advance ( n + 1 ) , & input. rest [ ..n] ) )
498
+ }
499
+
500
+ fn raw_string ( input : Cursor ) -> Result < Cursor , Reject > {
501
+ let ( input, delimiter) = delimiter_of_raw_string ( input) ?;
502
+ let mut chars = input. char_indices ( ) ;
498
503
while let Some ( ( i, ch) ) = chars. next ( ) {
499
504
match ch {
500
- '"' if input. rest [ i + 1 ..] . starts_with ( & input . rest [ ..n ] ) => {
501
- let rest = input. advance ( i + 1 + n ) ;
505
+ '"' if input. rest [ i + 1 ..] . starts_with ( delimiter ) => {
506
+ let rest = input. advance ( i + 1 + delimiter . len ( ) ) ;
502
507
return Ok ( literal_suffix ( rest) ) ;
503
508
}
504
509
'\r' => match chars. next ( ) {
You can’t perform that action at this time.
0 commit comments