1 | use regex_automata::DFA; |
2 | |
3 | use crate::unicode::fsm::{ |
4 | whitespace_anchored_fwd::WHITESPACE_ANCHORED_FWD, |
5 | whitespace_anchored_rev::WHITESPACE_ANCHORED_REV, |
6 | }; |
7 | |
8 | /// Return the first position of a non-whitespace character. |
9 | pub fn whitespace_len_fwd(slice: &[u8]) -> usize { |
10 | WHITESPACE_ANCHORED_FWD.find(slice).unwrap_or(default:0) |
11 | } |
12 | |
13 | /// Return the last position of a non-whitespace character. |
14 | pub fn whitespace_len_rev(slice: &[u8]) -> usize { |
15 | WHITESPACE_ANCHORED_REV.rfind(slice).unwrap_or(default:slice.len()) |
16 | } |
17 | |