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 //! # fn main() {
11 //! use std::ops::Mul;
12 //! use typenum::{Prod, P5, P7};
13 //!
14 //! type X = <P7 as Mul<P5>>::Output;
15 //! type Y = Prod<P7, P5>;
16 //!
17 //! assert_type_eq!(X, Y);
18 //! # }
19 //! ```
20 //!
21 //!
22 
23 // Aliases!!!
24 use core::ops::{Add, BitAnd, BitOr, BitXor, Div, Mul, Neg, Rem, Shl, Shr, Sub};
25 use type_operators::{Abs, Cmp, Gcd, Len, Logarithm2, Max, Min, PartialDiv, Pow, SquareRoot};
26 
27 /// Alias for the associated type of `BitAnd`: `And<A, B> = <A as BitAnd<B>>::Output`
28 pub type And<A, B> = <A as BitAnd<B>>::Output;
29 /// Alias for the associated type of `BitOr`: `Or<A, B> = <A as BitOr<B>>::Output`
30 pub type Or<A, B> = <A as BitOr<B>>::Output;
31 /// Alias for the associated type of `BitXor`: `Xor<A, B> = <A as BitXor<B>>::Output`
32 pub type Xor<A, B> = <A as BitXor<B>>::Output;
33 
34 /// Alias for the associated type of `Shl`: `Shleft<A, B> = <A as Shl<B>>::Output`
35 pub type Shleft<A, B> = <A as Shl<B>>::Output;
36 /// Alias for the associated type of `Shr`: `Shright<A, B> = <A as Shr<B>>::Output`
37 pub type Shright<A, B> = <A as Shr<B>>::Output;
38 
39 /// Alias for the associated type of `Add`: `Sum<A, B> = <A as Add<B>>::Output`
40 pub type Sum<A, B> = <A as Add<B>>::Output;
41 /// Alias for the associated type of `Sub`: `Diff<A, B> = <A as Sub<B>>::Output`
42 pub type Diff<A, B> = <A as Sub<B>>::Output;
43 /// Alias for the associated type of `Mul`: `Prod<A, B> = <A as Mul<B>>::Output`
44 pub type Prod<A, B> = <A as Mul<B>>::Output;
45 /// Alias for the associated type of `Div`: `Quot<A, B> = <A as Div<B>>::Output`
46 pub type Quot<A, B> = <A as Div<B>>::Output;
47 /// Alias for the associated type of `Rem`: `Mod<A, B> = <A as Rem<B>>::Output`
48 pub type Mod<A, B> = <A as Rem<B>>::Output;
49 
50 /// Alias for the associated type of
51 /// `PartialDiv`: `PartialQuot<A, B> = <A as PartialDiv<B>>::Output`
52 pub type PartialQuot<A, B> = <A as PartialDiv<B>>::Output;
53 
54 /// Alias for the associated type of `Neg`: `Negate<A> = <A as Neg>::Output`
55 pub type Negate<A> = <A as Neg>::Output;
56 
57 /// Alias for the associated type of `Abs`: `AbsVal<A> = <A as Abs>::Output`
58 pub type AbsVal<A> = <A as Abs>::Output;
59 
60 /// Alias for the associated type of `Pow`: `Exp<A, B> = <A as Pow<B>>::Output`
61 pub type Exp<A, B> = <A as Pow<B>>::Output;
62 
63 /// Alias for the associated type of `Gcd`: `Gcf<A, B> = <A as Gcd<B>>::Output>`
64 pub type Gcf<A, B> = <A as Gcd<B>>::Output;
65 
66 /// Alias to make it easy to add 1: `Add1<A> = <A as Add<B1>>::Output`
67 pub type Add1<A> = <A as Add<::bit::B1>>::Output;
68 /// Alias to make it easy to subtract 1: `Sub1<A> = <A as Sub<B1>>::Output`
69 pub type Sub1<A> = <A as Sub<::bit::B1>>::Output;
70 
71 /// Alias to make it easy to multiply by 2. `Double<A> = Shleft<A, B1>`
72 pub type Double<A> = Shleft<A, ::bit::B1>;
73 
74 /// Alias to make it easy to square. `Square<A> = <A as Mul<A>>::Output`
75 pub type Square<A> = <A as Mul>::Output;
76 /// Alias to make it easy to cube. `Cube<A> = <Square<A> as Mul<A>>::Output`
77 pub type Cube<A> = <Square<A> as Mul<A>>::Output;
78 
79 /// Alias for the associated type of `SquareRoot`: `Sqrt<A> = <A as SquareRoot>::Output`
80 pub type Sqrt<A> = <A as SquareRoot>::Output;
81 
82 /// Alias for the associated type of `Cmp`: `Compare<A, B> = <A as Cmp<B>>::Output`
83 pub type Compare<A, B> = <A as Cmp<B>>::Output;
84 
85 /// Alias for the associated type of `Len`: `Length<A> = <A as Len>::Output`
86 pub type Length<T> = <T as Len>::Output;
87 
88 /// Alias for the associated type of `Min`: `Minimum<A, B> = <A as Min<B>>::Output`
89 pub type Minimum<A, B> = <A as Min<B>>::Output;
90 
91 /// Alias for the associated type of `Max`: `Maximum<A, B> = <A as Max<B>>::Output`
92 pub type Maximum<A, B> = <A as Max<B>>::Output;
93 
94 use type_operators::{IsEqual, IsGreater, IsGreaterOrEqual, IsLess, IsLessOrEqual, IsNotEqual};
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