pub struct Eval<'a, T>(pub T, pub &'a str);
Expand description

Rule to constrain any type to a predicate

The value is always passed by its reference, the closure need to accept that

Example

use type_rules::prelude::*;

const EVEN_EVAL: for<'a> fn(&'a u32) -> bool = |v| v % 2 == 0;

#[derive(Validator)]
struct EvenInteger(
    #[rule(Eval(EVEN_EVAL, "Value need to be even"))]
    u32
);

Tuple Fields

0: T1: &'a str

Trait Implementations

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.