pub trait ConstInteger:
Default
+ Copy
+ Eq
+ Debug
+ 'static {
type SatDec: ConstInteger;
type Dec: ConstInteger;
type Inc: ConstInteger;
type ArrayOf<T>: ConstArray<Item = T, Cap = Self>;
type CopyArrayOf<T: Copy>: ConstArray<Item = T, Cap = Self, DecArray: Copy> + Copy;
const VALUE: usize;
const DEFAULT: Self;
// Provided methods
fn value(self) -> usize { ... }
fn sat_dec(self) -> Self::Dec { ... }
fn dec(self) -> Self::Dec { ... }
fn inc(self) -> Self::Inc { ... }
}
Expand description
Ala C++ integral_constant.
We need this machinery to fight against Rust’s half-baked const evaluation. With this, we can do const {Self::N+1} in stable rust.
Required Associated Constants§
Required Associated Types§
Sourcetype SatDec: ConstInteger
type SatDec: ConstInteger
Saturating decrement
type Dec: ConstInteger
type Inc: ConstInteger
Sourcetype ArrayOf<T>: ConstArray<Item = T, Cap = Self>
type ArrayOf<T>: ConstArray<Item = T, Cap = Self>
[T; Self::N]
Sourcetype CopyArrayOf<T: Copy>: ConstArray<Item = T, Cap = Self, DecArray: Copy> + Copy
type CopyArrayOf<T: Copy>: ConstArray<Item = T, Cap = Self, DecArray: Copy> + Copy
Same as Self::ArrayOf, but with additional type bounds.
N.B. We can’t just forward Copy for ArrayOf if T: Copy in Rust.
Provided Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.