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.15.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}
75
76#[cfg(not(feature = "force_unix_path_separator"))]
77mod generated {
78 include!(env!("TYPENUM_BUILD_OP"));
79 include!(env!("TYPENUM_BUILD_CONSTS"));
80}
81
82pub mod bit;
83pub mod int;
84pub mod marker_traits;
85pub mod operator_aliases;
86pub mod private;
87pub mod type_operators;
88pub mod uint;
89
90pub mod array;
91
92pub use crate::{
93 array::{ATerm, TArr},
94 consts::*,
95 generated::consts,
96 int::{NInt, PInt},
97 marker_traits::*,
98 operator_aliases::*,
99 type_operators::*,
100 uint::{UInt, UTerm},
101};
102
103#[derive(Eq, PartialEq, Ord, PartialOrd, Clone, Copy, Hash, Debug, Default)]
106#[cfg_attr(feature = "scale_info", derive(scale_info::TypeInfo))]
107pub struct Greater;
108
109#[derive(Eq, PartialEq, Ord, PartialOrd, Clone, Copy, Hash, Debug, Default)]
112#[cfg_attr(feature = "scale_info", derive(scale_info::TypeInfo))]
113pub struct Less;
114
115#[derive(Eq, PartialEq, Ord, PartialOrd, Clone, Copy, Hash, Debug, Default)]
118#[cfg_attr(feature = "scale_info", derive(scale_info::TypeInfo))]
119pub struct Equal;
120
121impl Ord for Greater {
123 #[inline]
124 fn to_ordering() -> Ordering {
125 Ordering::Greater
126 }
127}
128
129impl Ord for Less {
131 #[inline]
132 fn to_ordering() -> Ordering {
133 Ordering::Less
134 }
135}
136
137impl Ord for Equal {
139 #[inline]
140 fn to_ordering() -> Ordering {
141 Ordering::Equal
142 }
143}
144
145#[macro_export]
147macro_rules! assert_type_eq {
148 ($a:ty, $b:ty) => {
149 const _: core::marker::PhantomData<<$a as $crate::Same<$b>>::Output> =
150 core::marker::PhantomData;
151 };
152}
153
154#[macro_export]
156macro_rules! assert_type {
157 ($a:ty) => {
158 const _: core::marker::PhantomData<<$a as $crate::Same<True>>::Output> =
159 core::marker::PhantomData;
160 };
161}
162
163mod sealed {
164 use crate::{
165 ATerm, Bit, Equal, Greater, Less, NInt, NonZero, PInt, TArr, UInt, UTerm, Unsigned, B0, B1,
166 Z0,
167 };
168
169 pub trait Sealed {}
170
171 impl Sealed for B0 {}
172 impl Sealed for B1 {}
173
174 impl Sealed for UTerm {}
175 impl<U: Unsigned, B: Bit> Sealed for UInt<U, B> {}
176
177 impl Sealed for Z0 {}
178 impl<U: Unsigned + NonZero> Sealed for PInt<U> {}
179 impl<U: Unsigned + NonZero> Sealed for NInt<U> {}
180
181 impl Sealed for Less {}
182 impl Sealed for Equal {}
183 impl Sealed for Greater {}
184
185 impl Sealed for ATerm {}
186 impl<V, A> Sealed for TArr<V, A> {}
187}