Skip to main content

RefinementPredicate

Enum RefinementPredicate 

Source
pub enum RefinementPredicate {
Show 18 variants Equal(f64), NotEqual(f64), GreaterThan(f64), GreaterThanOrEqual(f64), LessThan(f64), LessThanOrEqual(f64), Range { min: f64, max: f64, }, RangeExclusive { min: f64, max: f64, }, Modulo { divisor: i64, remainder: i64, }, InSet(Vec<f64>), NotInSet(Vec<f64>), And(Vec<RefinementPredicate>), Or(Vec<RefinementPredicate>), Not(Box<RefinementPredicate>), Custom { name: String, description: String, checker: Arc<dyn Fn(f64) -> bool + Send + Sync>, }, Dependent { variable: String, relation: DependentRelation, }, StringLength { min: Option<usize>, max: Option<usize>, }, Pattern(String),
}
Expand description

A refinement predicate that constrains values.

Variants§

§

Equal(f64)

Value must equal a constant

§

NotEqual(f64)

Value must not equal a constant

§

GreaterThan(f64)

Value must be greater than a constant

§

GreaterThanOrEqual(f64)

Value must be greater than or equal to a constant

§

LessThan(f64)

Value must be less than a constant

§

LessThanOrEqual(f64)

Value must be less than or equal to a constant

§

Range

Value must be in a range [min, max]

Fields

§min: f64
§max: f64
§

RangeExclusive

Value must be in a half-open range [min, max)

Fields

§min: f64
§max: f64
§

Modulo

Value must satisfy a modulo constraint (value % divisor == remainder)

Fields

§divisor: i64
§remainder: i64
§

InSet(Vec<f64>)

Value must be in a set of allowed values

§

NotInSet(Vec<f64>)

Value must not be in a set of disallowed values

§

And(Vec<RefinementPredicate>)

Conjunction of predicates (all must be satisfied)

§

Or(Vec<RefinementPredicate>)

Disjunction of predicates (at least one must be satisfied)

§

Not(Box<RefinementPredicate>)

Negation of a predicate

§

Custom

Custom predicate with a name (for symbolic reasoning)

Fields

§name: String
§description: String
§checker: Arc<dyn Fn(f64) -> bool + Send + Sync>
§

Dependent

Dependent predicate referencing another variable

Fields

§variable: String
§

StringLength

String length constraint

Fields

§

Pattern(String)

Pattern match constraint (for strings)

Implementations§

Source§

impl RefinementPredicate

Source

pub fn greater_than(value: f64) -> Self

Create a “greater than” predicate.

Source

pub fn greater_than_or_equal(value: f64) -> Self

Create a “greater than or equal” predicate.

Source

pub fn less_than(value: f64) -> Self

Create a “less than” predicate.

Source

pub fn less_than_or_equal(value: f64) -> Self

Create a “less than or equal” predicate.

Source

pub fn range(min: f64, max: f64) -> Self

Create a range predicate [min, max].

Source

pub fn modulo(divisor: i64, remainder: i64) -> Self

Create a modulo constraint predicate.

Source

pub fn in_set(values: Vec<f64>) -> Self

Create a predicate requiring value to be in a set.

Source

pub fn and(predicates: Vec<RefinementPredicate>) -> Self

Create a conjunction of predicates.

Source

pub fn or(predicates: Vec<RefinementPredicate>) -> Self

Create a disjunction of predicates.

Source

pub fn not(predicate: RefinementPredicate) -> Self

Create a negation of a predicate.

Source

pub fn custom<F>( name: impl Into<String>, description: impl Into<String>, checker: F, ) -> Self
where F: Fn(f64) -> bool + Send + Sync + 'static,

Create a custom predicate with a checker function.

Source

pub fn dependent( variable: impl Into<String>, relation: DependentRelation, ) -> Self

Create a dependent predicate.

Source

pub fn check(&self, value: f64) -> bool

Check if a value satisfies this predicate.

Note: For dependent predicates, this returns true (use check_with_context instead).

Source

pub fn check_with_context( &self, value: f64, context: &RefinementContext, ) -> bool

Check if a value satisfies this predicate with a context for dependent predicates.

Source

pub fn free_variables(&self) -> Vec<String>

Get the free variables referenced by this predicate.

Source

pub fn simplify(&self) -> RefinementPredicate

Simplify the predicate by removing redundant constraints.

Source

pub fn to_string_repr(&self) -> String

Convert to a human-readable string.

Trait Implementations§

Source§

impl Clone for RefinementPredicate

Source§

fn clone(&self) -> RefinementPredicate

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for RefinementPredicate

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.