impl SentenceSegmenter { /// Construct a [`SentenceSegmenter`] using compiled data. This does not assume any content locale. #[diplomat::rust_link(icu::segmenter::SentenceSegmenter::new, FnInStruct)] #[diplomat::rust_link(
icu::segmenter::options::SentenceBreakInvariantOptions, Struct,
hidden
)] #[diplomat::attr(auto, constructor)] #[cfg(feature = "compiled_data")] pubfn create() -> Box<SentenceSegmenter> { Box::new(SentenceSegmenter(
icu_segmenter::SentenceSegmenter::new(Default::default()).static_to_owned(),
))
} /// Construct a [`SentenceSegmenter`] for content known to be of a given locale, using compiled data. #[diplomat::rust_link(icu::segmenter::SentenceSegmenter::try_new, FnInStruct, hidden)] #[diplomat::rust_link(icu::segmenter::options::SentenceBreakOptions, Struct, hidden)] #[diplomat::attr(all(supports = fallible_constructors, supports = named_constructors), named_constructor = "with_content_locale")] #[cfg(feature = "compiled_data")] pubfn create_with_content_locale(
locale: &Locale,
) -> Result<Box<SentenceSegmenter>, DataError> {
Ok(Box::new(SentenceSegmenter(
icu_segmenter::SentenceSegmenter::try_new(locale.into())?,
)))
}
/// Construct a [`SentenceSegmenter`] for content known to be of a given locale, using a particular data source. #[diplomat::rust_link(icu::segmenter::SentenceSegmenter::try_new, FnInStruct, hidden)] #[diplomat::attr(all(supports = fallible_constructors, supports = named_constructors), named_constructor = "with_content_locale_and_provider")] #[cfg(feature = "buffer_provider")] pubfn create_with_content_locale_and_provider(
provider: &DataProvider,
locale: &Locale,
) -> Result<Box<SentenceSegmenter>, DataError> {
Ok(Box::new(SentenceSegmenter(
icu_segmenter::SentenceSegmenter::try_new_with_buffer_provider(
provider.get()?,
locale.into(),
)?,
)))
}
/// Segments a string. /// /// Ill-formed input is treated as if errors had been replaced with REPLACEMENT CHARACTERs according /// to the WHATWG Encoding Standard. #[diplomat::rust_link(icu::segmenter::SentenceSegmenterBorrowed::segment_utf8, FnInStruct)] #[diplomat::rust_link(
icu::segmenter::SentenceSegmenterBorrowed::segment_str,
FnInStruct,
hidden
)] #[diplomat::attr(not(supports = utf8_strings), disable)] #[diplomat::attr(*, rename = "segment")] pubfn segment_utf8<'a>(
&'a self,
input: &'a DiplomatStr,
) -> Box<SentenceBreakIteratorUtf8<'a>> { Box::new(SentenceBreakIteratorUtf8( self.0.as_borrowed().segment_utf8(input),
))
}
/// Segments a string. /// /// Ill-formed input is treated as if errors had been replaced with REPLACEMENT CHARACTERs according /// to the WHATWG Encoding Standard. #[diplomat::rust_link(icu::segmenter::SentenceSegmenterBorrowed::segment_utf16, FnInStruct)] #[diplomat::attr(not(supports = utf8_strings), rename = "segment")] #[diplomat::attr(supports = utf8_strings, rename = "segment16")] pubfn segment_utf16<'a>(
&'a self,
input: &'a DiplomatStr16,
) -> Box<SentenceBreakIteratorUtf16<'a>> { Box::new(SentenceBreakIteratorUtf16( self.0.as_borrowed().segment_utf16(input),
))
}
impl<'a> SentenceBreakIteratorUtf8<'a> { /// Finds the next breakpoint. Returns -1 if at the end of the string or if the index is /// out of range of a 32-bit signed integer. #[diplomat::rust_link(icu::segmenter::iterators::SentenceBreakIterator::next, FnInStruct)] pubfn next(&mutself) -> i32 { self.0
.next()
.and_then(|u| i32::try_from(u).ok())
.unwrap_or(-1)
}
}
impl<'a> SentenceBreakIteratorUtf16<'a> { /// Finds the next breakpoint. Returns -1 if at the end of the string or if the index is /// out of range of a 32-bit signed integer. #[diplomat::rust_link(icu::segmenter::iterators::SentenceBreakIterator::next, FnInStruct)] pubfn next(&mutself) -> i32 { self.0
.next()
.and_then(|u| i32::try_from(u).ok())
.unwrap_or(-1)
}
}
impl<'a> SentenceBreakIteratorLatin1<'a> { /// Finds the next breakpoint. Returns -1 if at the end of the string or if the index is /// out of range of a 32-bit signed integer. #[diplomat::rust_link(icu::segmenter::iterators::SentenceBreakIterator::next, FnInStruct)] #[diplomat::rust_link(
icu::segmenter::iterators::SentenceBreakIterator::Item,
AssociatedTypeInStruct,
hidden
)] pubfn next(&mutself) -> i32 { self.0
.next()
.and_then(|u| i32::try_from(u).ok())
.unwrap_or(-1)
}
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.