1use crate::size::{IsGreaterOrEqual, IsLessOrEqual};
2use crate::{Sequence, StaticSize, ToUInt, U};
3use sealed::sealed;
4use typenum::{Const, Unsigned};
5
6#[sealed]
13pub unsafe trait LowerBound<N: Unsigned>: Sequence {}
14
15#[sealed]
22pub unsafe trait UpperBound<N: Unsigned>: Sequence {}
23
24#[rustfmt::skip]
25#[sealed]
26pub trait WithLowerBound<const N: usize>: LowerBound<U<N>>
27where
28 Const<N>: ToUInt,
29{}
30
31#[rustfmt::skip]
32#[sealed]
33impl<S, const N: usize> WithLowerBound<N> for S
34where
35 S: LowerBound<U<N>>,
36 Const<N>: ToUInt,
37{}
38
39#[rustfmt::skip]
40#[sealed]
41pub trait WithUpperBound<const N: usize>: UpperBound<U<N>>
42where
43 Const<N>: ToUInt,
44{}
45
46#[rustfmt::skip]
47#[sealed]
48impl<S, const N: usize> WithUpperBound<N> for S
49where
50 S: UpperBound<U<N>>,
51 Const<N>: ToUInt,
52{}
53
54#[rustfmt::skip]
55#[sealed]
56unsafe impl<S: Sequence, N: Unsigned> LowerBound<N> for S
57where
58 S::MinSize: IsGreaterOrEqual<StaticSize<N>>,
59{}
60
61#[rustfmt::skip]
62#[sealed]
63unsafe impl<S: Sequence, N: Unsigned> UpperBound<N> for S
64where
65 S::MinSize: IsLessOrEqual<StaticSize<N>>,
66{}