| 1 | //! Aliases for the type operators used in this crate. |
| 2 | |
| 3 | //! Their purpose is to increase the ergonomics of performing operations on the types defined |
| 4 | //! here. For even more ergonomics, consider using the `op!` macro instead. |
| 5 | //! |
| 6 | //! For example, type `X` and type `Y` are the same here: |
| 7 | //! |
| 8 | //! ```rust |
| 9 | //! # #[macro_use ] extern crate typenum; |
| 10 | //! use std::ops::Mul; |
| 11 | //! use typenum::{Prod, P5, P7}; |
| 12 | //! |
| 13 | //! type X = <P7 as Mul<P5>>::Output; |
| 14 | //! type Y = Prod<P7, P5>; |
| 15 | //! |
| 16 | //! assert_type_eq!(X, Y); |
| 17 | //! ``` |
| 18 | |
| 19 | // Aliases!!! |
| 20 | use crate::type_operators::{ |
| 21 | Abs, Cmp, Gcd, Len, Logarithm2, Max, Min, PartialDiv, Pow, SquareRoot, |
| 22 | }; |
| 23 | use core::ops::{Add, BitAnd, BitOr, BitXor, Div, Mul, Neg, Rem, Shl, Shr, Sub}; |
| 24 | |
| 25 | /// Alias for the associated type of `BitAnd`: `And<A, B> = <A as BitAnd<B>>::Output` |
| 26 | pub type And<A, B> = <A as BitAnd<B>>::Output; |
| 27 | /// Alias for the associated type of `BitOr`: `Or<A, B> = <A as BitOr<B>>::Output` |
| 28 | pub type Or<A, B> = <A as BitOr<B>>::Output; |
| 29 | /// Alias for the associated type of `BitXor`: `Xor<A, B> = <A as BitXor<B>>::Output` |
| 30 | pub type Xor<A, B> = <A as BitXor<B>>::Output; |
| 31 | |
| 32 | /// Alias for the associated type of `Shl`: `Shleft<A, B> = <A as Shl<B>>::Output` |
| 33 | pub type Shleft<A, B> = <A as Shl<B>>::Output; |
| 34 | /// Alias for the associated type of `Shr`: `Shright<A, B> = <A as Shr<B>>::Output` |
| 35 | pub type Shright<A, B> = <A as Shr<B>>::Output; |
| 36 | |
| 37 | /// Alias for the associated type of `Add`: `Sum<A, B> = <A as Add<B>>::Output` |
| 38 | pub type Sum<A, B> = <A as Add<B>>::Output; |
| 39 | /// Alias for the associated type of `Sub`: `Diff<A, B> = <A as Sub<B>>::Output` |
| 40 | pub type Diff<A, B> = <A as Sub<B>>::Output; |
| 41 | /// Alias for the associated type of `Mul`: `Prod<A, B> = <A as Mul<B>>::Output` |
| 42 | pub type Prod<A, B> = <A as Mul<B>>::Output; |
| 43 | /// Alias for the associated type of `Div`: `Quot<A, B> = <A as Div<B>>::Output` |
| 44 | pub type Quot<A, B> = <A as Div<B>>::Output; |
| 45 | /// Alias for the associated type of `Rem`: `Mod<A, B> = <A as Rem<B>>::Output` |
| 46 | pub type Mod<A, B> = <A as Rem<B>>::Output; |
| 47 | |
| 48 | /// Alias for the associated type of |
| 49 | /// `PartialDiv`: `PartialQuot<A, B> = <A as PartialDiv<B>>::Output` |
| 50 | pub type PartialQuot<A, B> = <A as PartialDiv<B>>::Output; |
| 51 | |
| 52 | /// Alias for the associated type of `Neg`: `Negate<A> = <A as Neg>::Output` |
| 53 | pub type Negate<A> = <A as Neg>::Output; |
| 54 | |
| 55 | /// Alias for the associated type of `Abs`: `AbsVal<A> = <A as Abs>::Output` |
| 56 | pub type AbsVal<A> = <A as Abs>::Output; |
| 57 | |
| 58 | /// Alias for the associated type of `Pow`: `Exp<A, B> = <A as Pow<B>>::Output` |
| 59 | pub type Exp<A, B> = <A as Pow<B>>::Output; |
| 60 | |
| 61 | /// Alias for the associated type of `Gcd`: `Gcf<A, B> = <A as Gcd<B>>::Output>` |
| 62 | pub type Gcf<A, B> = <A as Gcd<B>>::Output; |
| 63 | |
| 64 | /// Alias to make it easy to add 1: `Add1<A> = <A as Add<B1>>::Output` |
| 65 | pub type Add1<A> = <A as Add<crate::bit::B1>>::Output; |
| 66 | /// Alias to make it easy to subtract 1: `Sub1<A> = <A as Sub<B1>>::Output` |
| 67 | pub type Sub1<A> = <A as Sub<crate::bit::B1>>::Output; |
| 68 | |
| 69 | /// Alias to make it easy to multiply by 2. `Double<A> = Shleft<A, B1>` |
| 70 | pub type Double<A> = Shleft<A, crate::bit::B1>; |
| 71 | |
| 72 | /// Alias to make it easy to square. `Square<A> = <A as Mul<A>>::Output` |
| 73 | pub type Square<A> = <A as Mul>::Output; |
| 74 | /// Alias to make it easy to cube. `Cube<A> = <Square<A> as Mul<A>>::Output` |
| 75 | pub type Cube<A> = <Square<A> as Mul<A>>::Output; |
| 76 | |
| 77 | /// Alias for the associated type of `SquareRoot`: `Sqrt<A> = <A as SquareRoot>::Output` |
| 78 | pub type Sqrt<A> = <A as SquareRoot>::Output; |
| 79 | |
| 80 | /// Alias for the associated type of `Cmp`: `Compare<A, B> = <A as Cmp<B>>::Output` |
| 81 | pub type Compare<A, B> = <A as Cmp<B>>::Output; |
| 82 | |
| 83 | /// Alias for the associated type of `Len`: `Length<A> = <A as Len>::Output` |
| 84 | pub type Length<T> = <T as Len>::Output; |
| 85 | |
| 86 | /// Alias for the associated type of `Min`: `Minimum<A, B> = <A as Min<B>>::Output` |
| 87 | pub type Minimum<A, B> = <A as Min<B>>::Output; |
| 88 | |
| 89 | /// Alias for the associated type of `Max`: `Maximum<A, B> = <A as Max<B>>::Output` |
| 90 | pub type Maximum<A, B> = <A as Max<B>>::Output; |
| 91 | |
| 92 | use crate::type_operators::{ |
| 93 | IsEqual, IsGreater, IsGreaterOrEqual, IsLess, IsLessOrEqual, IsNotEqual, |
| 94 | }; |
| 95 | /// Alias for the associated type of `IsLess`: `Le<A, B> = <A as IsLess<B>>::Output` |
| 96 | pub type Le<A, B> = <A as IsLess<B>>::Output; |
| 97 | /// Alias for the associated type of `IsEqual`: `Eq<A, B> = <A as IsEqual<B>>::Output` |
| 98 | pub type Eq<A, B> = <A as IsEqual<B>>::Output; |
| 99 | /// Alias for the associated type of `IsGreater`: `Gr<A, B> = <A as IsGreater<B>>::Output` |
| 100 | pub type Gr<A, B> = <A as IsGreater<B>>::Output; |
| 101 | /// Alias for the associated type of `IsGreaterOrEqual`: |
| 102 | /// `GrEq<A, B> = <A as IsGreaterOrEqual<B>>::Output` |
| 103 | pub type GrEq<A, B> = <A as IsGreaterOrEqual<B>>::Output; |
| 104 | /// Alias for the associated type of `IsLessOrEqual`: `LeEq<A, B> = <A as IsLessOrEqual<B>>::Output` |
| 105 | pub type LeEq<A, B> = <A as IsLessOrEqual<B>>::Output; |
| 106 | /// Alias for the associated type of `IsNotEqual`: `NotEq<A, B> = <A as IsNotEqual<B>>::Output` |
| 107 | pub type NotEq<A, B> = <A as IsNotEqual<B>>::Output; |
| 108 | /// Alias for the associated type of `Logarithm2`: `Log2<A> = <A as Logarithm2>::Output` |
| 109 | pub type Log2<A> = <A as Logarithm2>::Output; |
| 110 | |