@@ -165,13 +165,26 @@ impl Lexer {
165165 self . remove_text ( self . current ) ;
166166 match self . remove_text ( self . current ) {
167167 x if x. is_ascii_hexdigit ( ) => match self . remove_text ( self . current ) {
168- y if y. is_ascii_hexdigit ( ) => { self . insert_text ( self . current , u8:: from_str_radix ( format ! ( "{x}{y}" ) . as_str ( ) , 16 ) . unwrap ( ) as char ) ;
169- self . advance ( ) ; } ,
170- y => { self . insert_text ( self . current , u8:: from_str_radix ( format ! ( "{x}" ) . as_str ( ) , 16 ) . unwrap ( ) as char ) ;
171- self . insert_text ( self . current +1 , y) ;
172- self . advance ( ) ; }
168+ y if y. is_ascii_hexdigit ( ) => {
169+ self . insert_text (
170+ self . current ,
171+ u8:: from_str_radix ( format ! ( "{x}{y}" ) . as_str ( ) , 16 ) . unwrap ( )
172+ as char ,
173+ ) ;
174+ self . advance ( ) ;
175+ }
176+ y => {
177+ self . insert_text (
178+ self . current ,
179+ u8:: from_str_radix ( format ! ( "{x}" ) . as_str ( ) , 16 ) . unwrap ( )
180+ as char ,
181+ ) ;
182+ self . insert_text ( self . current + 1 , y) ;
183+ self . advance ( ) ;
184+ }
173185 } ,
174- x => { self . insert_text ( self . current , x) ;
186+ x => {
187+ self . insert_text ( self . current , x) ;
175188 self . advance ( ) ;
176189 }
177190 }
@@ -186,7 +199,11 @@ impl Lexer {
186199 hex_string. push ( self . remove_text ( self . current ) ) ;
187200 i += 1 ;
188201 }
189- self . insert_text ( self . current , char:: from_u32 ( u32:: from_str_radix ( hex_string. as_str ( ) , 16 ) . unwrap ( ) ) . unwrap ( ) ) ;
202+ self . insert_text (
203+ self . current ,
204+ char:: from_u32 ( u32:: from_str_radix ( hex_string. as_str ( ) , 16 ) . unwrap ( ) )
205+ . unwrap ( ) ,
206+ ) ;
190207 self . current += 1 ;
191208 } else {
192209 error:: error (
@@ -197,7 +214,6 @@ impl Lexer {
197214 } else {
198215 self . advance ( ) ;
199216 }
200-
201217 }
202218 if self . is_at_end ( ) {
203219 error:: error ( self . line , "unterminated string" ) ;
@@ -306,15 +322,15 @@ impl Lexer {
306322 }
307323
308324 fn remove_text ( & mut self , pos : usize ) -> char {
309- // use chars to be able to use unicode, remove the pos
325+ // use chars to be able to use unicode, remove the pos
310326 let mut text: Vec < char > = self . source . chars ( ) . collect ( ) ;
311327 let to_return = text[ pos] ;
312328 text. remove ( pos) ;
313329 self . source = text. iter ( ) . collect ( ) ;
314330 to_return
315331 }
316332
317- fn insert_text ( & mut self , pos : usize , texts : char , ) {
333+ fn insert_text ( & mut self , pos : usize , texts : char ) {
318334 let mut text: Vec < char > = self . source . chars ( ) . collect ( ) ;
319335 text. insert ( pos, texts) ;
320336 self . source = text. iter ( ) . collect ( ) ;
0 commit comments