Type Alias typewit::type_fn::CallFn

source ·
pub type CallFn<F, T> = <F as TypeFn<T>>::Output;
Expand description

Calls the F type-level function with T as its argument.

For F:InjTypeFn<T>, it’s better to use CallInjFn instead of this type alias.

Example

use typewit::CallFn;
use core::ops::Mul;
 
assert_eq!(mul(3u8, &5u8), 15u8);
 
fn mul<L, R>(l: L, r: R) -> CallFn<MulOutput<L>, R> 
where
    L: core::ops::Mul<R>
{
    l * r
}
 
// Declares `struct MulOutput<Lhs>`,
// a type-level function from `Rhs` to the return type of `Lhs * Rhs`.
typewit::type_fn! {
    struct MulOutput<Lhs>;

    impl<Rhs> Rhs => <Lhs as Mul<Rhs>>::Output
    where Lhs: core::ops::Mul<Rhs>
}