@@ -331,24 +331,37 @@ pub fn is_whitespace(c: char) -> bool {
331331
332332    matches ! ( 
333333        c, 
334-         // Usual ASCII suspects 
335-         '\u{0009}'    // \t 
336-         | '\u{000A}'  // \n 
334+         // End-of-line characters 
335+         | '\u{000A}'  // line feed (\n) 
337336        | '\u{000B}'  // vertical tab 
338337        | '\u{000C}'  // form feed 
339-         | '\u{000D}'  // \r 
340-         | '\u{0020}'  // space 
341- 
342-         // NEXT LINE from latin1 
343-         | '\u{0085}' 
338+         | '\u{000D}'  // carriage return (\r) 
339+         | '\u{0085}'  // next line (from latin1) 
340+         | '\u{2028}'  // LINE SEPARATOR 
341+         | '\u{2029}'  // PARAGRAPH SEPARATOR 
344342
345-         // Bidi markers  
343+         // `Default_Ignorable_Code_Point` characters  
346344        | '\u{200E}'  // LEFT-TO-RIGHT MARK 
347345        | '\u{200F}'  // RIGHT-TO-LEFT MARK 
348346
349-         // Dedicated whitespace characters from Unicode 
350-         | '\u{2028}'  // LINE SEPARATOR 
351-         | '\u{2029}'  // PARAGRAPH SEPARATOR 
347+         // Horizontal space characters 
348+         | '\u{0009}'    // tab (\t) 
349+         | '\u{0020}'  // space 
350+     ) 
351+ } 
352+ 
353+ /// True if `c` is considered horizontal whitespace according to Rust language definition. 
354+ pub  fn  is_horizontal_whitespace ( c :  char )  -> bool  { 
355+     // This is Pattern_White_Space. 
356+     // 
357+     // Note that this set is stable (ie, it doesn't change with different 
358+     // Unicode versions), so it's ok to just hard-code the values. 
359+ 
360+     matches ! ( 
361+         c, 
362+         // Horizontal space characters 
363+         '\u{0009}'    // tab (\t) 
364+         | '\u{0020}'  // space 
352365    ) 
353366} 
354367
@@ -538,7 +551,7 @@ impl Cursor<'_> {
538551        debug_assert ! ( length_opening >= 3 ) ; 
539552
540553        // whitespace between the opening and the infostring. 
541-         self . eat_while ( |ch| ch != '\n'  && is_whitespace ( ch) ) ; 
554+         self . eat_while ( |ch| ch != '\n'  && is_horizontal_whitespace ( ch) ) ; 
542555
543556        // copied from `eat_identifier`, but allows `-` and `.` in infostring to allow something like 
544557        // `---Cargo.toml` as a valid opener 
@@ -547,7 +560,7 @@ impl Cursor<'_> {
547560            self . eat_while ( |c| is_id_continue ( c)  || c == '-'  || c == '.' ) ; 
548561        } 
549562
550-         self . eat_while ( |ch| ch != '\n'  && is_whitespace ( ch) ) ; 
563+         self . eat_while ( |ch| ch != '\n'  && is_horizontal_whitespace ( ch) ) ; 
551564        let  invalid_infostring = self . first ( )  != '\n' ; 
552565
553566        let  mut  found = false ; 
@@ -588,7 +601,7 @@ impl Cursor<'_> {
588601                // on a standalone line. Might be wrong. 
589602                while  let  Some ( closing)  = rest. find ( "---" )  { 
590603                    let  preceding_chars_start = rest[ ..closing] . rfind ( "\n " ) . map_or ( 0 ,  |i| i + 1 ) ; 
591-                     if  rest[ preceding_chars_start..closing] . chars ( ) . all ( is_whitespace )  { 
604+                     if  rest[ preceding_chars_start..closing] . chars ( ) . all ( is_horizontal_whitespace )  { 
592605                        // candidate found 
593606                        potential_closing = Some ( closing) ; 
594607                        break ; 
0 commit comments