1#![no_std]
43#![forbid(unsafe_code)]
44#![warn(missing_docs)]
45#![cfg_attr(feature = "strict", deny(missing_docs))]
46#![cfg_attr(feature = "strict", deny(warnings))]
47#![doc(html_root_url = "https://docs.rs/typenum/1.20.0")]
48#![cfg_attr(docsrs, feature(doc_cfg))]
49
50use core::cmp::Ordering;
55
56pub mod bit;
57mod gen;
58pub mod int;
59pub mod marker_traits;
60pub mod operator_aliases;
61pub mod private;
62pub mod type_operators;
63pub mod uint;
64
65pub mod array;
66pub mod tuple;
67
68pub use crate::{
69 array::{ATerm, TArr},
70 gen::consts,
71 int::{NInt, PInt},
72 marker_traits::*,
73 operator_aliases::*,
74 type_operators::*,
75 uint::{UInt, UTerm},
76};
77
78#[doc(no_inline)]
79#[rustfmt::skip]
80pub use consts::*;
81
82#[cfg(feature = "const-generics")]
83pub use crate::gen::generic_const_mappings;
84
85#[cfg(feature = "const-generics")]
86#[doc(no_inline)]
87pub use generic_const_mappings::{Const, ToUInt, U};
88
89#[derive(Eq, PartialEq, Ord, PartialOrd, Clone, Copy, Hash, Debug, Default)]
92#[cfg_attr(feature = "scale_info", derive(scale_info::TypeInfo))]
93pub struct Greater;
94
95#[derive(Eq, PartialEq, Ord, PartialOrd, Clone, Copy, Hash, Debug, Default)]
98#[cfg_attr(feature = "scale_info", derive(scale_info::TypeInfo))]
99pub struct Less;
100
101#[derive(Eq, PartialEq, Ord, PartialOrd, Clone, Copy, Hash, Debug, Default)]
104#[cfg_attr(feature = "scale_info", derive(scale_info::TypeInfo))]
105pub struct Equal;
106
107impl Ord for Greater {
109 #[inline]
110 fn to_ordering() -> Ordering {
111 Ordering::Greater
112 }
113}
114
115impl Ord for Less {
117 #[inline]
118 fn to_ordering() -> Ordering {
119 Ordering::Less
120 }
121}
122
123impl Ord for Equal {
125 #[inline]
126 fn to_ordering() -> Ordering {
127 Ordering::Equal
128 }
129}
130
131#[macro_export]
133macro_rules! assert_type_eq {
134 ($a:ty, $b:ty) => {
135 const _: core::marker::PhantomData<<$a as $crate::Same<$b>>::Output> =
136 core::marker::PhantomData;
137 };
138}
139
140#[macro_export]
142macro_rules! assert_type {
143 ($a:ty) => {
144 const _: core::marker::PhantomData<<$a as $crate::Same<True>>::Output> =
145 core::marker::PhantomData;
146 };
147}
148
149mod sealed {
150 use crate::{
151 ATerm, Bit, Equal, Greater, Less, NInt, NonZero, PInt, TArr, UInt, UTerm, Unsigned, B0, B1,
152 Z0,
153 };
154
155 pub trait Sealed {}
156
157 impl Sealed for B0 {}
158 impl Sealed for B1 {}
159
160 impl Sealed for UTerm {}
161 impl<U: Unsigned, B: Bit> Sealed for UInt<U, B> {}
162
163 impl Sealed for Z0 {}
164 impl<U: Unsigned + NonZero> Sealed for PInt<U> {}
165 impl<U: Unsigned + NonZero> Sealed for NInt<U> {}
166
167 impl Sealed for Less {}
168 impl Sealed for Equal {}
169 impl Sealed for Greater {}
170
171 impl Sealed for ATerm {}
172 impl<V, A> Sealed for TArr<V, A> {}
173}