pub enum Assertion {
Equals(f64),
NotEquals(f64),
GreaterThan(f64),
GreaterThanOrEqual(f64),
LessThan(f64),
LessThanOrEqual(f64),
Between(f64, f64),
NotBetween(f64, f64),
}Expand description
An assertion that can be evaluated against a numeric value.
Used by statistical constraints to define success criteria.
§Examples
use term_guard::constraints::Assertion;
// Value must equal 100
let assertion = Assertion::Equals(100.0);
assert!(assertion.evaluate(100.0));
// Value must be greater than 50
let assertion = Assertion::GreaterThan(50.0);
assert!(assertion.evaluate(75.0));
// Value must be between 10 and 20
let assertion = Assertion::Between(10.0, 20.0);
assert!(assertion.evaluate(15.0));Variants§
Equals(f64)
Value must equal the specified value (with epsilon tolerance)
NotEquals(f64)
Value must not equal the specified value
GreaterThan(f64)
Value must be greater than the specified value
GreaterThanOrEqual(f64)
Value must be greater than or equal to the specified value
LessThan(f64)
Value must be less than the specified value
LessThanOrEqual(f64)
Value must be less than or equal to the specified value
Between(f64, f64)
Value must be between the specified range (inclusive)
NotBetween(f64, f64)
Value must not be between the specified range
Implementations§
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Assertion
impl<'de> Deserialize<'de> for Assertion
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl StructuralPartialEq for Assertion
Auto Trait Implementations§
impl Freeze for Assertion
impl RefUnwindSafe for Assertion
impl Send for Assertion
impl Sync for Assertion
impl Unpin for Assertion
impl UnwindSafe for Assertion
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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