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.17.0")]
63#![cfg_attr(docsrs, feature(doc_auto_cfg, doc_cfg))]
64
65use core::cmp::Ordering;
70
71mod generated {
72 include!(concat!(env!("OUT_DIR"), "/op.rs"));
73 include!(concat!(env!("OUT_DIR"), "/consts.rs"));
74
75 #[cfg(feature = "const-generics")]
76 include!(concat!(env!("OUT_DIR"), "/generic_const_mappings.rs"));
77}
78
79pub mod bit;
80pub mod int;
81pub mod marker_traits;
82pub mod operator_aliases;
83pub mod private;
84pub mod type_operators;
85pub mod uint;
86
87pub mod array;
88
89pub use crate::{
90 array::{ATerm, TArr},
91 generated::consts,
92 int::{NInt, PInt},
93 marker_traits::*,
94 operator_aliases::*,
95 type_operators::*,
96 uint::{UInt, UTerm},
97};
98
99#[doc(no_inline)]
100#[rustfmt::skip]
101pub use consts::{
102 False, True, B0, B1,
103 U0, U1, U2, *,
104 N1, N2, Z0, P1, P2, *,
105};
106
107#[cfg(feature = "const-generics")]
108pub use crate::generated::generic_const_mappings;
109
110#[cfg(feature = "const-generics")]
111#[doc(no_inline)]
112pub use generic_const_mappings::{Const, ToUInt, U};
113
114#[derive(Eq, PartialEq, Ord, PartialOrd, Clone, Copy, Hash, Debug, Default)]
117#[cfg_attr(feature = "scale_info", derive(scale_info::TypeInfo))]
118pub struct Greater;
119
120#[derive(Eq, PartialEq, Ord, PartialOrd, Clone, Copy, Hash, Debug, Default)]
123#[cfg_attr(feature = "scale_info", derive(scale_info::TypeInfo))]
124pub struct Less;
125
126#[derive(Eq, PartialEq, Ord, PartialOrd, Clone, Copy, Hash, Debug, Default)]
129#[cfg_attr(feature = "scale_info", derive(scale_info::TypeInfo))]
130pub struct Equal;
131
132impl Ord for Greater {
134 #[inline]
135 fn to_ordering() -> Ordering {
136 Ordering::Greater
137 }
138}
139
140impl Ord for Less {
142 #[inline]
143 fn to_ordering() -> Ordering {
144 Ordering::Less
145 }
146}
147
148impl Ord for Equal {
150 #[inline]
151 fn to_ordering() -> Ordering {
152 Ordering::Equal
153 }
154}
155
156#[macro_export]
158macro_rules! assert_type_eq {
159 ($a:ty, $b:ty) => {
160 const _: core::marker::PhantomData<<$a as $crate::Same<$b>>::Output> =
161 core::marker::PhantomData;
162 };
163}
164
165#[macro_export]
167macro_rules! assert_type {
168 ($a:ty) => {
169 const _: core::marker::PhantomData<<$a as $crate::Same<True>>::Output> =
170 core::marker::PhantomData;
171 };
172}
173
174mod sealed {
175 use crate::{
176 ATerm, Bit, Equal, Greater, Less, NInt, NonZero, PInt, TArr, UInt, UTerm, Unsigned, B0, B1,
177 Z0,
178 };
179
180 pub trait Sealed {}
181
182 impl Sealed for B0 {}
183 impl Sealed for B1 {}
184
185 impl Sealed for UTerm {}
186 impl<U: Unsigned, B: Bit> Sealed for UInt<U, B> {}
187
188 impl Sealed for Z0 {}
189 impl<U: Unsigned + NonZero> Sealed for PInt<U> {}
190 impl<U: Unsigned + NonZero> Sealed for NInt<U> {}
191
192 impl Sealed for Less {}
193 impl Sealed for Equal {}
194 impl Sealed for Greater {}
195
196 impl Sealed for ATerm {}
197 impl<V, A> Sealed for TArr<V, A> {}
198}