Struct typewit::type_fn::FnRev

source ·
pub struct FnRev<F: ?Sized>(/* private fields */);
Expand description

Reverses an InjTypeFn, its arguments become return values, and its return values become arguments.

§Examples

§Permutations

The different ways this function can be combined with CallFn and UncallFn

use typewit::type_fn::{CallFn, FnRev, UncallFn};
 
let _: CallFn<FnRev<Swap>, Right> = Left;
let _: UncallFn<    Swap,  Right> = Left;
 
let _: CallFn<        Swap,  Up> = Down;
let _: UncallFn<FnRev<Swap>, Up> = Down;
 
typewit::inj_type_fn!{
    struct Swap;
 
    impl Left => Right;
    impl Up   => Down;
}
 
struct Left;
struct Right;
struct Up;
struct Down;

Implementations§

source§

impl<F: ?Sized> FnRev<F>

source

pub const NEW: Self = _

Constructs a FnRev.

source§

impl<F> FnRev<F>

source

pub const fn from_ref(_f: &F) -> Self

Constructs a FnRev from &F

Trait Implementations§

source§

impl<F, R: ?Sized> RevTypeFn<R> for FnRev<F>
where F: InjTypeFn<R>,

§

type Arg = <F as InjTypeFn<R>>::Ret

The argument to this function with Ret as the return value.
source§

impl<F, A: ?Sized> TypeFn<A> for FnRev<F>
where F: RevTypeFn<A>,

§

type Output = <F as RevTypeFn<A>>::Arg

The return value of the function
source§

const TYPE_FN_ASSERTS: () = ()

Helper constant for adding asserts in the TypeFn impl;

Auto Trait Implementations§

§

impl<F> Freeze for FnRev<F>
where F: ?Sized,

§

impl<F> RefUnwindSafe for FnRev<F>
where F: ?Sized,

§

impl<F> Send for FnRev<F>
where F: ?Sized,

§

impl<F> Sync for FnRev<F>
where F: ?Sized,

§

impl<F> Unpin for FnRev<F>
where F: ?Sized,

§

impl<F> UnwindSafe for FnRev<F>
where F: ?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, W> HasTypeWitness<W> for T
where W: MakeTypeWitness<Arg = T>, T: ?Sized,

source§

const WITNESS: W = const WITNESS: W = W::MAKE;

A constant of the type witness
source§

impl<T> Identity for T
where T: ?Sized,

§

type Type = T

The same type as Self, used to emulate type equality bounds (T == U) with associated type equality constraints (T: Identity<Type = U>).
source§

const TYPE_EQ: TypeEq<T, <T as Identity>::Type> = const TYPE_EQ: TypeEq<Self, Self::Type> = TypeEq::NEW;

Proof that Self is the same type as Self::Type, provides methods for casting between Self and Self::Type.
source§

impl<F, A, R> InjTypeFn<A> for F
where F: RevTypeFn<R, Output = R, Arg = A> + TypeFn<A>, A: ?Sized, R: ?Sized,

§

type Ret = R

Return value of the function
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>,

§

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>,

§

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.