Finds the first whitespace character in UTF-8 encoded text. Searches for any of the 29 Unicode whitespace characters (includes all newlines per Unicode standard, plus spaces, tabs, and various Unicode space characters). The complete set includes: - All 8 newline characters (see [`find_newline_utf8`]) - U+0009 (CHARACTER TABULATION `\t`) - U+001F (UNIT SEPARATOR) - U+0020 (SPACE) - U+00A0 (NO-BRE
(text: T)
| 1827 | /// assert_eq!(span.length, 1); |
| 1828 | /// ``` |
| 1829 | pub fn find_whitespace_utf8<T>(text: T) -> Option<IndexSpan> |
| 1830 | where |
| 1831 | T: AsRef<[u8]>, |
| 1832 | { |
| 1833 | let text_ref = text.as_ref(); |
| 1834 | let text_pointer = text_ref.as_ptr() as *const c_void; |
| 1835 | let text_length = text_ref.len(); |
| 1836 | let mut matched_length: usize = 0; |
| 1837 | |
| 1838 | let result = unsafe { sz_utf8_find_whitespace(text_pointer, text_length, &mut matched_length as *mut usize) }; |
| 1839 | |
| 1840 | if result.is_null() { |
| 1841 | None |
| 1842 | } else { |
| 1843 | let offset = unsafe { (result as *const u8).offset_from(text_pointer as *const u8) } |
| 1844 | .try_into() |
| 1845 | .unwrap(); |
| 1846 | Some(IndexSpan::new(offset, matched_length)) |
| 1847 | } |
| 1848 | } |
| 1849 | |
| 1850 | /// Counts the number of UTF-8 characters in the text. |
| 1851 | /// |
searching dependent graphs…