diff options
Diffstat (limited to 'vendor/bstr/src/unicode/sentence.rs')
-rw-r--r-- | vendor/bstr/src/unicode/sentence.rs | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/vendor/bstr/src/unicode/sentence.rs b/vendor/bstr/src/unicode/sentence.rs index ff29c7e25..0baf4dfeb 100644 --- a/vendor/bstr/src/unicode/sentence.rs +++ b/vendor/bstr/src/unicode/sentence.rs @@ -1,4 +1,4 @@ -use regex_automata::DFA; +use regex_automata::{dfa::Automaton, Anchored, Input}; use crate::{ ext_slice::ByteSlice, @@ -145,9 +145,12 @@ impl<'a> Iterator for SentenceIndices<'a> { fn decode_sentence(bs: &[u8]) -> (&str, usize) { if bs.is_empty() { ("", 0) - } else if let Some(end) = SENTENCE_BREAK_FWD.find(bs) { + } else if let Some(hm) = { + let input = Input::new(bs).anchored(Anchored::Yes); + SENTENCE_BREAK_FWD.try_search_fwd(&input).unwrap() + } { // Safe because a match can only occur for valid UTF-8. - let sentence = unsafe { bs[..end].to_str_unchecked() }; + let sentence = unsafe { bs[..hm.offset()].to_str_unchecked() }; (sentence, sentence.len()) } else { const INVALID: &'static str = "\u{FFFD}"; |