Trait Constraint

Source
pub trait Constraint<T> {
    // Required method
    fn check(value: &T) -> Result<(), ConstraintError>;
}
Expand description

A trait for enforcing numeric invariants at construction time.

Implement this trait for any marker type representing a numeric constraint, such as NonNegative or StrictlyPositive.

Required Methods§

Source

fn check(value: &T) -> Result<(), ConstraintError>

Checks that the given value satisfies this constraint.

§Errors

Returns a ConstraintError if the value does not satisfy the constraint.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§