MatchConfigBuilder

Struct MatchConfigBuilder 

Source
pub struct MatchConfigBuilder<'a, S: State = Empty> { /* private fields */ }
Expand description

Use builder syntax to set the inputs and finish with build().

Implementations§

Source§

impl<'a, S: State> MatchConfigBuilder<'a, S>

Source

pub fn build(self) -> MatchConfig<'a>
where S: IsComplete,

Finish building and return the requested object

Source

pub fn analyze(self, value: bool) -> MatchConfigBuilder<'a, SetAnalyze<S>>
where S::Analyze: IsUnset,

Optional (Some / Option setters). Default: false.

For more advanced control over the analysis, use MatchConfigBuilder::analyze_config.

Source

pub fn maybe_analyze( self, value: Option<bool>, ) -> MatchConfigBuilder<'a, SetAnalyze<S>>
where S::Analyze: IsUnset,

Optional (Some / Option setters). Default: false.

For more advanced control over the analysis, use MatchConfigBuilder::analyze_config.

Source

pub fn analyze_config( self, value: PatternAnalyzeConfig, ) -> MatchConfigBuilder<'a, SetAnalyzeConfig<S>>
where S::AnalyzeConfig: IsUnset,

Optional (Some / Option setters).

Source

pub fn maybe_analyze_config( self, value: Option<PatternAnalyzeConfig>, ) -> MatchConfigBuilder<'a, SetAnalyzeConfig<S>>
where S::AnalyzeConfig: IsUnset,

Optional (Some / Option setters).

Source

pub fn is_pattern_partial( self, value: bool, ) -> MatchConfigBuilder<'a, SetIsPatternPartial<S>>
where S::IsPatternPartial: IsUnset,

Optional (Some / Option setters). Default: false.

If true, the pattern can match pinyins/romajis starting with the ending of the pattern.

For example, pattern “pinyi” can match “拼音” (whose pinyin is “pinyin”) if is_pattern_partial is true.

Source

pub fn maybe_is_pattern_partial( self, value: Option<bool>, ) -> MatchConfigBuilder<'a, SetIsPatternPartial<S>>
where S::IsPatternPartial: IsUnset,

Optional (Some / Option setters). Default: false.

If true, the pattern can match pinyins/romajis starting with the ending of the pattern.

For example, pattern “pinyi” can match “拼音” (whose pinyin is “pinyin”) if is_pattern_partial is true.

Source

pub fn starts_with( self, value: bool, ) -> MatchConfigBuilder<'a, SetStartsWith<S>>
where S::StartsWith: IsUnset,

Optional (Some / Option setters). Default: false.

Only matches if the haystack starts with the pattern.

Source

pub fn maybe_starts_with( self, value: Option<bool>, ) -> MatchConfigBuilder<'a, SetStartsWith<S>>
where S::StartsWith: IsUnset,

Optional (Some / Option setters). Default: false.

Only matches if the haystack starts with the pattern.

Source

pub fn ends_with(self, value: bool) -> MatchConfigBuilder<'a, SetEndsWith<S>>
where S::EndsWith: IsUnset,

Optional (Some / Option setters). Default: false.

Only matches if the haystack ends with the pattern.

Source

pub fn maybe_ends_with( self, value: Option<bool>, ) -> MatchConfigBuilder<'a, SetEndsWith<S>>
where S::EndsWith: IsUnset,

Optional (Some / Option setters). Default: false.

Only matches if the haystack ends with the pattern.

Source

pub fn plain( self, value: Option<PlainMatchConfig>, ) -> MatchConfigBuilder<'a, SetPlain<S>>
where S::Plain: IsUnset,

Optional (Some / Option setters). Default: Some(PlainMatchConfig::builder().build()).

None means not to match characters in the pattern as plain characters, i.e. match them only as pinyin/romaji, even if they are not valid pinyin/romaji characters.

Note empty pattern always match everything.

Source

pub fn maybe_plain( self, value: Option<Option<PlainMatchConfig>>, ) -> MatchConfigBuilder<'a, SetPlain<S>>
where S::Plain: IsUnset,

Optional (Some / Option setters). Default: Some(PlainMatchConfig::builder().build()).

None means not to match characters in the pattern as plain characters, i.e. match them only as pinyin/romaji, even if they are not valid pinyin/romaji characters.

Note empty pattern always match everything.

Source

pub fn mix_lang(self, value: bool) -> MatchConfigBuilder<'a, SetMixLang<S>>
where S::MixLang: IsUnset,

Optional (Some / Option setters). Default: false.

Allow to match a haystack with mixed languages, i.e. pinyin and romaji, at the same time.

true may lead to unexpected matches, especially if [PinyinNotation::AsciiFirstLetter] is enabled, and also lower performance.

Source

pub fn maybe_mix_lang( self, value: Option<bool>, ) -> MatchConfigBuilder<'a, SetMixLang<S>>
where S::MixLang: IsUnset,

Optional (Some / Option setters). Default: false.

Allow to match a haystack with mixed languages, i.e. pinyin and romaji, at the same time.

true may lead to unexpected matches, especially if [PinyinNotation::AsciiFirstLetter] is enabled, and also lower performance.

Source

pub fn pinyin( self, value: PinyinMatchConfig<'a>, ) -> MatchConfigBuilder<'a, SetPinyin<S>>
where S::Pinyin: IsUnset,

Optional (Some / Option setters).

Source

pub fn maybe_pinyin( self, value: Option<PinyinMatchConfig<'a>>, ) -> MatchConfigBuilder<'a, SetPinyin<S>>
where S::Pinyin: IsUnset,

Optional (Some / Option setters).

Source

pub fn romaji( self, value: RomajiMatchConfig<'a>, ) -> MatchConfigBuilder<'a, SetRomaji<S>>
where S::Romaji: IsUnset,

Optional (Some / Option setters).

Source

pub fn maybe_romaji( self, value: Option<RomajiMatchConfig<'a>>, ) -> MatchConfigBuilder<'a, SetRomaji<S>>
where S::Romaji: IsUnset,

Optional (Some / Option setters).

Source§

impl<'a, S: State> MatchConfigBuilder<'a, S>

Source

pub fn case_insensitive( self, case_insensitive: bool, ) -> MatchConfigBuilder<'a, SetPlain<S>>
where S::Plain: IsUnset,

A convenient setter for PlainMatchConfigBuilder::case_insensitive.

The case insensitivity of pinyin is controlled by PinyinMatchConfigBuilder::case_insensitive.

Auto Trait Implementations§

§

impl<'a, S = Empty> !Freeze for MatchConfigBuilder<'a, S>

§

impl<'a, S> RefUnwindSafe for MatchConfigBuilder<'a, S>

§

impl<'a, S> Send for MatchConfigBuilder<'a, S>

§

impl<'a, S> Sync for MatchConfigBuilder<'a, S>

§

impl<'a, S> Unpin for MatchConfigBuilder<'a, S>

§

impl<'a, S> UnwindSafe for MatchConfigBuilder<'a, S>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.