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