@@ -292,6 +292,14 @@ trait MatchContextDrive {
292292 let this = !self . at_end ( ) && word_checker ( self . peek_char ( ) ) ;
293293 this != that
294294 }
295+ fn at_non_boundary < F : FnMut ( u32 ) -> bool > ( & self , mut word_checker : F ) -> bool {
296+ if self . at_beginning ( ) && self . at_end ( ) {
297+ return false ;
298+ }
299+ let that = !self . at_beginning ( ) && word_checker ( self . back_peek_char ( ) ) ;
300+ let this = !self . at_end ( ) && word_checker ( self . peek_char ( ) ) ;
301+ this == that
302+ }
295303 fn back_peek_char ( & self ) -> u32 {
296304 self . state ( ) . string . back_peek ( self . ctx ( ) . string_offset )
297305 }
@@ -738,14 +746,14 @@ fn at(drive: &StackDrive, atcode: SreAtCode) -> bool {
738746 SreAtCode :: BEGINNING | SreAtCode :: BEGINNING_STRING => drive. at_beginning ( ) ,
739747 SreAtCode :: BEGINNING_LINE => drive. at_beginning ( ) || is_linebreak ( drive. back_peek_char ( ) ) ,
740748 SreAtCode :: BOUNDARY => drive. at_boundary ( is_word) ,
741- SreAtCode :: NON_BOUNDARY => ! drive. at_boundary ( is_word) ,
749+ SreAtCode :: NON_BOUNDARY => drive. at_non_boundary ( is_word) ,
742750 SreAtCode :: END => ( drive. remaining_chars ( ) == 1 && drive. at_linebreak ( ) ) || drive. at_end ( ) ,
743751 SreAtCode :: END_LINE => drive. at_linebreak ( ) || drive. at_end ( ) ,
744752 SreAtCode :: END_STRING => drive. at_end ( ) ,
745753 SreAtCode :: LOC_BOUNDARY => drive. at_boundary ( is_loc_word) ,
746- SreAtCode :: LOC_NON_BOUNDARY => ! drive. at_boundary ( is_loc_word) ,
754+ SreAtCode :: LOC_NON_BOUNDARY => drive. at_non_boundary ( is_loc_word) ,
747755 SreAtCode :: UNI_BOUNDARY => drive. at_boundary ( is_uni_word) ,
748- SreAtCode :: UNI_NON_BOUNDARY => ! drive. at_boundary ( is_uni_word) ,
756+ SreAtCode :: UNI_NON_BOUNDARY => drive. at_non_boundary ( is_uni_word) ,
749757 }
750758}
751759
0 commit comments