[go: up one dir, main page]

Function zip3

Source
pub const fn zip3<A, B, C>(wit0: A, wit1: B, wit2: C) -> Zip3Out<A, B, C>
where A: BaseTypeWitness + Zip3<B, C>, A::L: Sized, A::R: Sized, B: BaseTypeWitness, B::L: Sized, B::R: Sized, C: BaseTypeWitness,
Available on crate feature rust_1_65 only.
Expand description

Zips together three BaseTypeWitness types.

§Return type

The return type depends on the types of the arguments:

  • if all arguments are TypeEq, this returns a TypeEq
  • if any argument is a TypeNe, this returns a TypeNe
  • if any argument is a TypeCmp and no argument is a TypeNe, this returns a TypeCmp

§Example

§Basic

This example shows basic usage.

use typewit::{TypeCmp, TypeEq, TypeNe, type_eq, type_ne};
use typewit::methods::zip3;

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, i64), (B, A, i64)> = zip3(eq, eq.flip(), type_eq::<i64>());

    let _: TypeNe<(A, B, B), (B, A, C)> = zip3(eq, eq.flip(), ne);

    let _: TypeCmp<(A, D, B), (B, E, A)> = zip3(eq, cmp, eq.flip());
}