pub const fn zip2<A, B>(wit0: A, wit1: B) -> Zip2Out<A, B>
Available on crate feature
rust_1_65
only.Expand description
Zips together two BaseTypeWitness
types.
Return type
The return type depends on the types of the arguments:
- if all arguments are
TypeEq
, this returns aTypeEq
- if any argument is a
TypeNe
, this returns aTypeNe
- if any argument is a
TypeCmp
and no argument is aTypeNe
, this returns aTypeCmp
Example
Basic
This example shows all permutations of argument and return types.
use typewit::{TypeCmp, TypeEq, TypeNe, type_ne};
use typewit::methods::zip2;
with::<u8, u8, bool, u16, u32>(
TypeEq::NEW,
type_ne!(u8, bool),
TypeCmp::Ne(type_ne!(u16, u32)),
);
const fn with<A, B, C, D, E>(eq: TypeEq<A, B>, ne: TypeNe<B, C>, cmp: TypeCmp<D, E>) {
let _: TypeEq<(A, B), (B, A)> = zip2(eq, eq.flip());
let _: TypeNe<(A, B), (B, C)> = zip2(eq, ne);
let _: TypeCmp<(A, D), (B, E)> = zip2(eq, cmp);
let _: TypeNe<(B, A), (C, B)> = zip2(ne, eq);
let _: TypeNe<(B, C), (C, B)> = zip2(ne, ne.flip());
let _: TypeNe<(B, D), (C, E)> = zip2(ne, cmp);
let _: TypeCmp<(D, A), (E, B)> = zip2(cmp, eq);
let _: TypeNe<(D, B), (E, C)> = zip2(cmp, ne);
let _: TypeCmp<(D, E), (E, D)> = zip2(cmp, cmp.flip());
}