Skip to main content

ClosureRule

Struct ClosureRule 

Source
pub struct ClosureRule<T: ?Sized> { /* private fields */ }
Expand description

Adapter wrapping a sync closure as a Rule (used by .refine(...)).

Implementations§

Source§

impl<T: ?Sized> ClosureRule<T>

Source

pub fn new(f: impl Fn(&T) -> bool + Send + Sync + 'static) -> Self

Wraps a closure under the default name "refine-0".

Source

pub fn with_ordinal( ordinal: usize, f: impl Fn(&T) -> bool + Send + Sync + 'static, ) -> Self

Ordinal-based name ("refine-3"), stable within a schema instance. The formatted name is owned by the rule; nothing is leaked.

Trait Implementations§

Source§

impl<T: ?Sized> Debug for ClosureRule<T>

Debug output shows only the stable name (closures are not printable).

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<T: ?Sized> Rule<T> for ClosureRule<T>

Source§

fn name(&self) -> &str

Stable identifier for the rule, used for diagnostics and Debug output only. In v0 it is NOT embedded in issue params and NOT surfaced via shape(); surfacing remains a candidate future contract change. Borrowed from the rule itself so generated names need no 'static interning.
Source§

fn validate(&self, value: &T) -> Option<RefineRejection>

Returns rejection data on failure; None on pass.

Auto Trait Implementations§

§

impl<T> !RefUnwindSafe for ClosureRule<T>

§

impl<T> !UnwindSafe for ClosureRule<T>

§

impl<T> Freeze for ClosureRule<T>
where Box<dyn Fn(&T) -> bool + Sync + Send>: Freeze, T: ?Sized,

§

impl<T> Send for ClosureRule<T>
where Box<dyn Fn(&T) -> bool + Sync + Send>: Send, T: ?Sized,

§

impl<T> Sync for ClosureRule<T>
where Box<dyn Fn(&T) -> bool + Sync + Send>: Sync, T: ?Sized,

§

impl<T> Unpin for ClosureRule<T>
where Box<dyn Fn(&T) -> bool + Sync + Send>: Unpin, T: ?Sized,

§

impl<T> UnsafeUnpin for ClosureRule<T>
where Box<dyn Fn(&T) -> bool + Sync + Send>: UnsafeUnpin, T: ?Sized,

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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.