1#![no_std]
46#![forbid(unsafe_code)]
47#![warn(missing_docs)]
48#![cfg_attr(feature = "strict", deny(missing_docs))]
49#![cfg_attr(feature = "strict", deny(warnings))]
50#![cfg_attr(
51 feature = "cargo-clippy",
52 allow(
53 clippy::len_without_is_empty,
54 clippy::many_single_char_names,
55 clippy::new_without_default,
56 clippy::suspicious_arithmetic_impl,
57 clippy::type_complexity,
58 clippy::wrong_self_convention,
59 )
60)]
61#![cfg_attr(feature = "cargo-clippy", deny(clippy::missing_inline_in_public_items))]
62#![doc(html_root_url = "https://docs.rs/typenum/1.16.0")]
63
64use core::cmp::Ordering;
69
70#[cfg(feature = "force_unix_path_separator")]
71mod generated {
72 include!(concat!(env!("OUT_DIR"), "/op.rs"));
73 include!(concat!(env!("OUT_DIR"), "/consts.rs"));
74 #[cfg(feature = "const-generics")]
75 include!(concat!(env!("OUT_DIR"), "/generic_const_mappings.rs"));
76}
77
78#[cfg(not(feature = "force_unix_path_separator"))]
79mod generated {
80 include!(env!("TYPENUM_BUILD_OP"));
81 include!(env!("TYPENUM_BUILD_CONSTS"));
82 #[cfg(feature = "const-generics")]
83 include!(env!("TYPENUM_BUILD_GENERIC_CONSTS"));
84}
85
86pub mod bit;
87pub mod int;
88pub mod marker_traits;
89pub mod operator_aliases;
90pub mod private;
91pub mod type_operators;
92pub mod uint;
93
94pub mod array;
95
96pub use crate::{
97 array::{ATerm, TArr},
98 generated::consts,
99 int::{NInt, PInt},
100 marker_traits::*,
101 operator_aliases::*,
102 type_operators::*,
103 uint::{UInt, UTerm},
104};
105
106#[doc(no_inline)]
107#[rustfmt::skip]
108pub use consts::{
109 False, True, B0, B1,
110 U0, U1, U2, *,
111 N1, N2, Z0, P1, P2, *,
112};
113
114#[cfg(feature = "const-generics")]
115pub use crate::generated::generic_const_mappings;
116
117#[cfg(feature = "const-generics")]
118#[doc(no_inline)]
119pub use generic_const_mappings::{Const, ToUInt, U};
120
121#[derive(Eq, PartialEq, Ord, PartialOrd, Clone, Copy, Hash, Debug, Default)]
124#[cfg_attr(feature = "scale_info", derive(scale_info::TypeInfo))]
125pub struct Greater;
126
127#[derive(Eq, PartialEq, Ord, PartialOrd, Clone, Copy, Hash, Debug, Default)]
130#[cfg_attr(feature = "scale_info", derive(scale_info::TypeInfo))]
131pub struct Less;
132
133#[derive(Eq, PartialEq, Ord, PartialOrd, Clone, Copy, Hash, Debug, Default)]
136#[cfg_attr(feature = "scale_info", derive(scale_info::TypeInfo))]
137pub struct Equal;
138
139impl Ord for Greater {
141 #[inline]
142 fn to_ordering() -> Ordering {
143 Ordering::Greater
144 }
145}
146
147impl Ord for Less {
149 #[inline]
150 fn to_ordering() -> Ordering {
151 Ordering::Less
152 }
153}
154
155impl Ord for Equal {
157 #[inline]
158 fn to_ordering() -> Ordering {
159 Ordering::Equal
160 }
161}
162
163#[macro_export]
165macro_rules! assert_type_eq {
166 ($a:ty, $b:ty) => {
167 const _: core::marker::PhantomData<<$a as $crate::Same<$b>>::Output> =
168 core::marker::PhantomData;
169 };
170}
171
172#[macro_export]
174macro_rules! assert_type {
175 ($a:ty) => {
176 const _: core::marker::PhantomData<<$a as $crate::Same<True>>::Output> =
177 core::marker::PhantomData;
178 };
179}
180
181mod sealed {
182 use crate::{
183 ATerm, Bit, Equal, Greater, Less, NInt, NonZero, PInt, TArr, UInt, UTerm, Unsigned, B0, B1,
184 Z0,
185 };
186
187 pub trait Sealed {}
188
189 impl Sealed for B0 {}
190 impl Sealed for B1 {}
191
192 impl Sealed for UTerm {}
193 impl<U: Unsigned, B: Bit> Sealed for UInt<U, B> {}
194
195 impl Sealed for Z0 {}
196 impl<U: Unsigned + NonZero> Sealed for PInt<U> {}
197 impl<U: Unsigned + NonZero> Sealed for NInt<U> {}
198
199 impl Sealed for Less {}
200 impl Sealed for Equal {}
201 impl Sealed for Greater {}
202
203 impl Sealed for ATerm {}
204 impl<V, A> Sealed for TArr<V, A> {}
205}