Struct Requires

Source
pub struct Requires<C, Raise, Err>
where C: Fn(Vector) -> Vector, Raise: FnOnce() -> Err,
{ pub cond: C, /* private fields */ }
Available on crate feature require only.
Expand description

Requires is the final representation of a requirement, usable in the requirements! macro.

When you use the requirement! macro it will expand into a constant function which returns a Requires instance.

§Generics

  • C: The required condition
  • Raise: If the requirement was not fulfilled this is invoked to raise the corresponding Err
  • Err: The error to Raise if the requirement was not fulfilled

Fields§

§cond: C

The required condition

Implementations§

Source§

impl<C, Raise, Err> Requires<C, Raise, Err>
where C: Fn(Vector) -> Vector, Raise: FnOnce() -> Err,

Source

pub const fn new(cond: C, raise: Raise) -> Self

Create a new Requires instance

Trait Implementations§

Source§

impl<C, Raise, Err> Condition for Requires<C, Raise, Err>
where C: Fn(Vector) -> Vector, Raise: FnOnce() -> Err,

Source§

fn check(&mut self, vector: Vector) -> MoveMask

Compute the condition over the vector, if any bit was set update seen to true.

§Returns

The MoveMask used to extract the condition result, used to check validity of the input, ensuring each byte fulfilled at least one condition.

Source§

type Error = Err

The error type associated with the requirement. When used in requirements all the error types must implement Into to a common type.
Source§

fn ok(self) -> Result<(), Self::Error>

Check that the condition was met at least once, used internally by the requirements! macro

Auto Trait Implementations§

§

impl<C, Raise, Err> Freeze for Requires<C, Raise, Err>
where C: Freeze, Raise: Freeze,

§

impl<C, Raise, Err> RefUnwindSafe for Requires<C, Raise, Err>
where C: RefUnwindSafe, Raise: RefUnwindSafe,

§

impl<C, Raise, Err> Send for Requires<C, Raise, Err>
where C: Send, Raise: Send,

§

impl<C, Raise, Err> Sync for Requires<C, Raise, Err>
where C: Sync, Raise: Sync,

§

impl<C, Raise, Err> Unpin for Requires<C, Raise, Err>
where C: Unpin, Raise: Unpin,

§

impl<C, Raise, Err> UnwindSafe for Requires<C, Raise, Err>
where C: UnwindSafe, Raise: UnwindSafe,

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 = 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.