]> git.proxmox.com Git - cargo.git/blob - vendor/typenum/src/operator_aliases.rs
New upstream version 0.33.0
[cargo.git] / vendor / typenum / src / operator_aliases.rs
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, Len, Max, Min, PartialDiv, Pow};
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 to make it easy to add 1: `Add1<A> = <A as Add<B1>>::Output`
64 pub type Add1<A> = <A as Add<::bit::B1>>::Output;
65 /// Alias to make it easy to subtract 1: `Sub1<A> = <A as Sub<B1>>::Output`
66 pub type Sub1<A> = <A as Sub<::bit::B1>>::Output;
67
68 /// Alias to make it easy to square. `Square<A> = <A as Mul<A>>::Output`
69 pub type Square<A> = <A as Mul>::Output;
70 /// Alias to make it easy to cube. `Cube<A> = <Square<A> as Mul<A>>::Output`
71 pub type Cube<A> = <Square<A> as Mul<A>>::Output;
72
73 /// Alias for the associated type of `Cmp`: `Compare<A, B> = <A as Cmp<B>>::Output`
74 pub type Compare<A, B> = <A as Cmp<B>>::Output;
75
76 /// Alias for the associated type of `Len`: `Length<A> = <A as Len>::Output`
77 pub type Length<T> = <T as Len>::Output;
78
79 /// Alias for the associated type of `Min`: `Minimum<A, B> = <A as Min<B>>::Output`
80 pub type Minimum<A, B> = <A as Min<B>>::Output;
81
82 /// Alias for the associated type of `Max`: `Maximum<A, B> = <A as Max<B>>::Output`
83 pub type Maximum<A, B> = <A as Max<B>>::Output;
84
85 use type_operators::{IsEqual, IsGreater, IsGreaterOrEqual, IsLess, IsLessOrEqual, IsNotEqual};
86 /// Alias for the associated type of `IsLess`: `Le<A, B> = <A as IsLess<B>>::Output`
87 pub type Le<A, B> = <A as IsLess<B>>::Output;
88 /// Alias for the associated type of `IsEqual`: `Eq<A, B> = <A as IsEqual<B>>::Output`
89 pub type Eq<A, B> = <A as IsEqual<B>>::Output;
90 /// Alias for the associated type of `IsGreater`: `Gr<A, B> = <A as IsGreater<B>>::Output`
91 pub type Gr<A, B> = <A as IsGreater<B>>::Output;
92 /// Alias for the associated type of `IsGreaterOrEqual`:
93 /// `GrEq<A, B> = <A as IsGreaterOrEqual<B>>::Output`
94 pub type GrEq<A, B> = <A as IsGreaterOrEqual<B>>::Output;
95 /// Alias for the associated type of `IsLessOrEqual`: `LeEq<A, B> = <A as IsLessOrEqual<B>>::Output`
96 pub type LeEq<A, B> = <A as IsLessOrEqual<B>>::Output;
97 /// Alias for the associated type of `IsNotEqual`: `NotEq<A, B> = <A as IsNotEqual<B>>::Output`
98 pub type NotEq<A, B> = <A as IsNotEqual<B>>::Output;