@@ -756,7 +756,7 @@ impl<'a> UWordBounds<'a> {
756756///
757757/// Any other single ASCII byte is its own boundary (the default WB999).
758758#[ derive( Debug ) ]
759- pub struct AsciiWordBoundIter < ' a > {
759+ struct AsciiWordBoundIter < ' a > {
760760rest : & ' a str ,
761761offset : usize ,
762762}
@@ -988,7 +988,7 @@ pub fn new_word_bound_indices(s: &str) -> UWordBoundIndices<'_> {
988988}
989989
990990#[ inline]
991- pub fn new_ascii_word_bound_indices ( s : & str ) ->AsciiWordBoundIter < ' _ > {
991+ fn new_ascii_word_bound_indices ( s : & str ) ->AsciiWordBoundIter < ' _ > {
992992AsciiWordBoundIter :: new ( s)
993993}
994994
@@ -1046,6 +1046,20 @@ mod tests {
10461046assert_eq ! ( cat, wd:: WC_Numeric ) ;
10471047}
10481048
1049+ #[ test]
1050+ fn test_ascii_word_bound_indices_various_cases ( ) {
1051+ let s ="Hello, world!" ;
1052+ let words: Vec < ( usize , & str ) > =new_ascii_word_bound_indices ( s) . collect ( ) ;
1053+ let expected =vec ! [
1054+ ( 0 , "Hello" ) , // simple letters
1055+ ( 5 , "," ) ,
1056+ ( 6 , " " ) , // space after comma
1057+ ( 7 , "world" ) , // skip comma+space, stop at '!'
1058+ ( 12 , "!" ) , // punctuation at the end
1059+ ] ;
1060+ assert_eq ! ( words, expected) ;
1061+ }
1062+
10491063#[ test]
10501064fn test_ascii_word_indices_various_cases ( ) {
10511065let s ="Hello, world! can't e.g. var1 123,456 foo_bar example.com 127.0.0.1:9090" ;