File tree Expand file tree Collapse file tree 1 file changed +4
-10
lines changed
Expand file tree Collapse file tree 1 file changed +4
-10
lines changed Original file line number Diff line number Diff line change @@ -20,16 +20,10 @@ pub fn scan_str_lit(lit: &Literal) -> TokenStream {
2020 . peekable ( ) ;
2121 let mut output = quote ! ( "" ) ;
2222 let mut last_part = String :: new ( ) ;
23- fn extend_last_part ( last_part : & mut String , ch : char ) {
24- if last_part. is_empty ( ) {
25- last_part. push ( '"' ) ; // start new string literal
26- }
27- last_part. push ( ch) ;
28- }
2923 fn seal_last_part ( last_part : & mut String , output : & mut TokenStream ) {
3024 if !last_part. is_empty ( ) {
31- last_part . push ( '"' ) ; // seal it
32- let l = syn:: parse_str :: < Literal > ( & last_part ) . unwrap ( ) ;
25+ let lit_str = format ! ( " \" {} \" " , last_part ) ;
26+ let l = syn:: parse_str :: < Literal > ( & lit_str ) . unwrap ( ) ;
3327 output. extend ( quote ! ( + #l) ) ;
3428 last_part. clear ( ) ;
3529 }
@@ -39,7 +33,7 @@ pub fn scan_str_lit(lit: &Literal) -> TokenStream {
3933 if ch == '$' {
4034 if iter. peek ( ) == Some ( & '$' ) {
4135 iter. next ( ) ;
42- extend_last_part ( & mut last_part, '$' ) ;
36+ last_part. push ( '$' ) ;
4337 continue ;
4438 }
4539
@@ -74,7 +68,7 @@ pub fn scan_str_lit(lit: &Literal) -> TokenStream {
7468 output. extend ( quote ! ( + "$" ) ) ;
7569 }
7670 } else {
77- extend_last_part ( & mut last_part, ch) ;
71+ last_part. push ( ch) ;
7872 }
7973 }
8074 seal_last_part ( & mut last_part, & mut output) ;
You can’t perform that action at this time.
0 commit comments