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#![doc(html_root_url = "https://docs.rs/typenum/1.18.0")]
51#![cfg_attr(docsrs, feature(doc_auto_cfg, doc_cfg))]
52
53use core::cmp::Ordering;
58
59pub mod bit;
60mod gen;
61pub mod int;
62pub mod marker_traits;
63pub mod operator_aliases;
64pub mod private;
65pub mod type_operators;
66pub mod uint;
67
68pub mod array;
69
70pub use crate::{
71    array::{ATerm, TArr},
72    gen::consts,
73    int::{NInt, PInt},
74    marker_traits::*,
75    operator_aliases::*,
76    type_operators::*,
77    uint::{UInt, UTerm},
78};
79
80#[doc(no_inline)]
81#[rustfmt::skip]
82pub use consts::*;
83
84#[cfg(feature = "const-generics")]
85pub use crate::gen::generic_const_mappings;
86
87#[cfg(feature = "const-generics")]
88#[doc(no_inline)]
89pub use generic_const_mappings::{Const, ToUInt, U};
90
91#[derive(Eq, PartialEq, Ord, PartialOrd, Clone, Copy, Hash, Debug, Default)]
94#[cfg_attr(feature = "scale_info", derive(scale_info::TypeInfo))]
95pub struct Greater;
96
97#[derive(Eq, PartialEq, Ord, PartialOrd, Clone, Copy, Hash, Debug, Default)]
100#[cfg_attr(feature = "scale_info", derive(scale_info::TypeInfo))]
101pub struct Less;
102
103#[derive(Eq, PartialEq, Ord, PartialOrd, Clone, Copy, Hash, Debug, Default)]
106#[cfg_attr(feature = "scale_info", derive(scale_info::TypeInfo))]
107pub struct Equal;
108
109impl Ord for Greater {
111    #[inline]
112    fn to_ordering() -> Ordering {
113        Ordering::Greater
114    }
115}
116
117impl Ord for Less {
119    #[inline]
120    fn to_ordering() -> Ordering {
121        Ordering::Less
122    }
123}
124
125impl Ord for Equal {
127    #[inline]
128    fn to_ordering() -> Ordering {
129        Ordering::Equal
130    }
131}
132
133#[macro_export]
135macro_rules! assert_type_eq {
136    ($a:ty, $b:ty) => {
137        const _: core::marker::PhantomData<<$a as $crate::Same<$b>>::Output> =
138            core::marker::PhantomData;
139    };
140}
141
142#[macro_export]
144macro_rules! assert_type {
145    ($a:ty) => {
146        const _: core::marker::PhantomData<<$a as $crate::Same<True>>::Output> =
147            core::marker::PhantomData;
148    };
149}
150
151mod sealed {
152    use crate::{
153        ATerm, Bit, Equal, Greater, Less, NInt, NonZero, PInt, TArr, UInt, UTerm, Unsigned, B0, B1,
154        Z0,
155    };
156
157    pub trait Sealed {}
158
159    impl Sealed for B0 {}
160    impl Sealed for B1 {}
161
162    impl Sealed for UTerm {}
163    impl<U: Unsigned, B: Bit> Sealed for UInt<U, B> {}
164
165    impl Sealed for Z0 {}
166    impl<U: Unsigned + NonZero> Sealed for PInt<U> {}
167    impl<U: Unsigned + NonZero> Sealed for NInt<U> {}
168
169    impl Sealed for Less {}
170    impl Sealed for Equal {}
171    impl Sealed for Greater {}
172
173    impl Sealed for ATerm {}
174    impl<V, A> Sealed for TArr<V, A> {}
175}