Fix formatting

This commit is contained in:
Dirkjan Ochtman 2021-02-10 13:10:38 +01:00
parent cd06fbecc8
commit 4338ff2c0c
1 changed files with 3 additions and 15 deletions

View File

@ -58,11 +58,7 @@ impl Segmenter {
/// segmentation; passing it in allows the callers to reuse the cache allocations. /// segmentation; passing it in allows the callers to reuse the cache allocations.
/// ///
/// The segmentation result can be retrieved through the `Search::split()` method. /// The segmentation result can be retrieved through the `Search::split()` method.
pub fn segment( pub fn segment(&self, input: &str, search: &mut Search) -> Result<(), InvalidCharacter> {
&self,
input: &str,
search: &mut Search,
) -> Result<(), InvalidCharacter> {
SegmentState::new(Ascii::new(input)?, &self, search).run(); SegmentState::new(Ascii::new(input)?, &self, search).run();
Ok(()) Ok(())
} }
@ -106,17 +102,9 @@ struct SegmentState<'a> {
} }
impl<'a> SegmentState<'a> { impl<'a> SegmentState<'a> {
fn new( fn new(text: Ascii<'a>, data: &'a Segmenter, search: &'a mut Search) -> Self {
text: Ascii<'a>,
data: &'a Segmenter,
search: &'a mut Search,
) -> Self {
search.clear(); search.clear();
Self { Self { data, text, search }
data,
text,
search,
}
} }
/// Returns a list of words that is the best segmentation of `text` /// Returns a list of words that is the best segmentation of `text`