1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
#![no_std]
#![forbid(unsafe_code)]
#![warn(missing_docs)]
#![cfg_attr(feature = "strict", deny(missing_docs))]
#![cfg_attr(feature = "strict", deny(warnings))]
#![cfg_attr(
feature = "cargo-clippy",
allow(
clippy::len_without_is_empty,
clippy::many_single_char_names,
clippy::new_without_default,
clippy::suspicious_arithmetic_impl,
clippy::type_complexity,
clippy::wrong_self_convention,
)
)]
#![cfg_attr(feature = "cargo-clippy", deny(clippy::missing_inline_in_public_items))]
#![doc(html_root_url = "https://docs.rs/typenum/1.17.0")]
#![cfg_attr(docsrs, feature(doc_auto_cfg, doc_cfg))]
use core::cmp::Ordering;
mod generated {
include!(concat!(env!("OUT_DIR"), "/op.rs"));
include!(concat!(env!("OUT_DIR"), "/consts.rs"));
#[cfg(feature = "const-generics")]
include!(concat!(env!("OUT_DIR"), "/generic_const_mappings.rs"));
}
pub mod bit;
pub mod int;
pub mod marker_traits;
pub mod operator_aliases;
pub mod private;
pub mod type_operators;
pub mod uint;
pub mod array;
pub use crate::{
array::{ATerm, TArr},
generated::consts,
int::{NInt, PInt},
marker_traits::*,
operator_aliases::*,
type_operators::*,
uint::{UInt, UTerm},
};
#[doc(no_inline)]
#[rustfmt::skip]
pub use consts::{
False, True, B0, B1,
U0, U1, U2, *,
N1, N2, Z0, P1, P2, *,
};
#[cfg(feature = "const-generics")]
pub use crate::generated::generic_const_mappings;
#[cfg(feature = "const-generics")]
#[doc(no_inline)]
pub use generic_const_mappings::{Const, ToUInt, U};
#[derive(Eq, PartialEq, Ord, PartialOrd, Clone, Copy, Hash, Debug, Default)]
#[cfg_attr(feature = "scale_info", derive(scale_info::TypeInfo))]
pub struct Greater;
#[derive(Eq, PartialEq, Ord, PartialOrd, Clone, Copy, Hash, Debug, Default)]
#[cfg_attr(feature = "scale_info", derive(scale_info::TypeInfo))]
pub struct Less;
#[derive(Eq, PartialEq, Ord, PartialOrd, Clone, Copy, Hash, Debug, Default)]
#[cfg_attr(feature = "scale_info", derive(scale_info::TypeInfo))]
pub struct Equal;
impl Ord for Greater {
#[inline]
fn to_ordering() -> Ordering {
Ordering::Greater
}
}
impl Ord for Less {
#[inline]
fn to_ordering() -> Ordering {
Ordering::Less
}
}
impl Ord for Equal {
#[inline]
fn to_ordering() -> Ordering {
Ordering::Equal
}
}
#[macro_export]
macro_rules! assert_type_eq {
($a:ty, $b:ty) => {
const _: core::marker::PhantomData<<$a as $crate::Same<$b>>::Output> =
core::marker::PhantomData;
};
}
#[macro_export]
macro_rules! assert_type {
($a:ty) => {
const _: core::marker::PhantomData<<$a as $crate::Same<True>>::Output> =
core::marker::PhantomData;
};
}
mod sealed {
use crate::{
ATerm, Bit, Equal, Greater, Less, NInt, NonZero, PInt, TArr, UInt, UTerm, Unsigned, B0, B1,
Z0,
};
pub trait Sealed {}
impl Sealed for B0 {}
impl Sealed for B1 {}
impl Sealed for UTerm {}
impl<U: Unsigned, B: Bit> Sealed for UInt<U, B> {}
impl Sealed for Z0 {}
impl<U: Unsigned + NonZero> Sealed for PInt<U> {}
impl<U: Unsigned + NonZero> Sealed for NInt<U> {}
impl Sealed for Less {}
impl Sealed for Equal {}
impl Sealed for Greater {}
impl Sealed for ATerm {}
impl<V, A> Sealed for TArr<V, A> {}
}