File tree 1 file changed +7
-4
lines changed
1 file changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -274,6 +274,7 @@ impl<'a> Tokenizer<'a> {
274
274
275
275
#[ inline]
276
276
pub fn position ( & self ) -> SourcePosition {
277
+ debug_assert ! ( self . input. is_char_boundary( self . position) ) ;
277
278
SourcePosition ( self . position )
278
279
}
279
280
@@ -313,13 +314,15 @@ impl<'a> Tokenizer<'a> {
313
314
}
314
315
315
316
#[ inline]
316
- pub fn slice_from ( & self , start_pos : SourcePosition ) -> & ' a str {
317
- & self . input [ start_pos. 0 .. self . position ]
317
+ pub ( crate ) fn slice_from ( & self , start_pos : SourcePosition ) -> & ' a str {
318
+ self . slice ( start_pos.. self . position ( ) )
318
319
}
319
320
320
321
#[ inline]
321
- pub fn slice ( & self , range : Range < SourcePosition > ) -> & ' a str {
322
- & self . input [ range. start . 0 ..range. end . 0 ]
322
+ pub ( crate ) fn slice ( & self , range : Range < SourcePosition > ) -> & ' a str {
323
+ debug_assert ! ( self . input. is_char_boundary( range. start. 0 ) ) ;
324
+ debug_assert ! ( self . input. is_char_boundary( range. end. 0 ) ) ;
325
+ unsafe { self . input . get_unchecked ( range. start . 0 ..range. end . 0 ) }
323
326
}
324
327
325
328
pub fn current_source_line ( & self ) -> & ' a str {
You can’t perform that action at this time.
0 commit comments