pub struct MatcherBuilder<'a, T: Matchable> { /* private fields */ }Expand description
A builder for creating matchers with a fluent API
§Example
use condition_matcher::{MatcherBuilder, MatcherMode, ConditionOperator, Matcher};
let matcher = MatcherBuilder::<i32>::new()
.mode(MatcherMode::AND)
.value_equals(42)
.build();
assert!(matcher.matches(&42));Implementations§
Source§impl<'a, T: Matchable + 'static> MatcherBuilder<'a, T>
impl<'a, T: Matchable + 'static> MatcherBuilder<'a, T>
Sourcepub fn mode(self, mode: ConditionMode) -> Self
pub fn mode(self, mode: ConditionMode) -> Self
Set the matching mode
Sourcepub fn value_equals(self, expected: T) -> Self
pub fn value_equals(self, expected: T) -> Self
Add a condition that the value equals the expected value
Sourcepub fn value_not_equals(self, expected: T) -> Self
pub fn value_not_equals(self, expected: T) -> Self
Add a condition that the value does not equal the expected value
Sourcepub fn length(self, len: usize, operator: ConditionOperator) -> Self
pub fn length(self, len: usize, operator: ConditionOperator) -> Self
Add a length condition
Sourcepub fn length_equals(self, len: usize) -> Self
pub fn length_equals(self, len: usize) -> Self
Add a condition that length equals the expected value
Sourcepub fn length_gte(self, len: usize) -> Self
pub fn length_gte(self, len: usize) -> Self
Add a condition that length is greater than or equal to the expected value
Sourcepub fn length_lte(self, len: usize) -> Self
pub fn length_lte(self, len: usize) -> Self
Add a condition that length is less than or equal to the expected value
Sourcepub fn build(self) -> RuleMatcher<'a, T>
pub fn build(self) -> RuleMatcher<'a, T>
Build the matcher
Trait Implementations§
Auto Trait Implementations§
impl<'a, T> Freeze for MatcherBuilder<'a, T>
impl<'a, T> !RefUnwindSafe for MatcherBuilder<'a, T>
impl<'a, T> !Send for MatcherBuilder<'a, T>
impl<'a, T> !Sync for MatcherBuilder<'a, T>
impl<'a, T> Unpin for MatcherBuilder<'a, T>where
T: Unpin,
impl<'a, T> !UnwindSafe for MatcherBuilder<'a, T>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more