@@ -279,7 +279,7 @@ pub struct Parser<'a, L: Language> {
279279 src : & ' a str ,
280280 index : usize ,
281281 language_items : & ' static [ ParseItem ] ,
282- _marker : PhantomData < L >
282+ _marker : PhantomData < L > ,
283283}
284284
285285// most this is only used in tests atm!
@@ -290,7 +290,7 @@ impl<L: Language> Parser<'_, L> {
290290 src,
291291 language_items : L :: PARSE_ITEMS ,
292292 index : 0 ,
293- _marker : PhantomData :: default ( )
293+ _marker : PhantomData :: default ( ) ,
294294 }
295295 }
296296
@@ -304,18 +304,22 @@ impl<L: Language> Parser<'_, L> {
304304 . find_map ( |i| Some ( ( i, items[ i] . begin ( ) . matches ( src) ?) ) )
305305 . and_then ( |( i, matches) | {
306306 ( matches[ 2 ] . end ..src. len ( ) ) . find_map ( |b| {
307- Some ( (
308- i,
309- b,
310- if items[ i] . is_key_matched ( ) {
311- items[ i] . end ( ) . matches_with_key (
312- & src[ b..] ,
313- & src[ matches[ 1 ] . start ..matches[ 1 ] . end ] ,
314- ) ?
315- } else {
316- items[ i] . end ( ) . matches ( & src[ b..] ) ?
317- } ,
318- ) )
307+ if src. is_char_boundary ( b) {
308+ Some ( (
309+ i,
310+ b,
311+ if items[ i] . is_key_matched ( ) {
312+ items[ i] . end ( ) . matches_with_key (
313+ & src[ b..] ,
314+ & src[ matches[ 1 ] . start ..matches[ 1 ] . end ] ,
315+ ) ?
316+ } else {
317+ items[ i] . end ( ) . matches ( & src[ b..] ) ?
318+ } ,
319+ ) )
320+ } else {
321+ None
322+ }
319323 } )
320324 } )
321325 {
0 commit comments