typewit::type_fn

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

Source§

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

Source§

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,

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§

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§

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

Source§

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

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.