[][src]Struct len_constraints::slice::Relative

pub struct Relative<'a, T, Op: Operator, By: TypeNum> { /* fields omitted */ }

An immutable slice with a relative length as length constraint

Note: Unlike the other constrained slices, this type does not necessarily validate the constraint on construction but on deconstruction (self.try_into())

Methods

impl<'a, T, Op: Operator, By: TypeNum> Relative<'a, T, Op, By>[src]

pub fn try_from(
    slice: &'a [T],
    relative_to: usize
) -> Result<Self, Box<dyn Error + 'static>>
[src]

Validates slice against the length constraint and creates the constrained slice with it

pub fn slice(
    self,
    relative_to: usize
) -> Result<&'a [T], Box<dyn Error + 'static>>
[src]

Computes the expected relative length from relative_to, validates the wrapped slice against in and returns it on success

Trait Implementations

impl<'a, T: Clone, Op: Clone + Operator, By: Clone + TypeNum> Clone for Relative<'a, T, Op, By>[src]

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl<'a, T, Op: Operator, By: TypeNum> From<&'a [T]> for Relative<'a, T, Op, By>[src]

fn from(slice: &'a [T]) -> Self[src]

Creates a new relative constrained slice

impl<'a, T: Copy, Op: Copy + Operator, By: Copy + TypeNum> Copy for Relative<'a, T, Op, By>[src]

impl<'a, T: Debug, Op: Debug + Operator, By: Debug + TypeNum> Debug for Relative<'a, T, Op, By>[src]

Auto Trait Implementations

impl<'a, T, Op, By> Send for Relative<'a, T, Op, By> where
    By: Send,
    Op: Send,
    T: Sync

impl<'a, T, Op, By> Sync for Relative<'a, T, Op, By> where
    By: Sync,
    Op: Sync,
    T: Sync

Blanket Implementations

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]