2 #![cfg_attr(full, feature(const_generics))]
3 #![cfg_attr(full, allow(incomplete_features))]
4 #![cfg_attr(min, feature(min_const_generics))]
6 struct PhantomU8<const X: u8>;
9 type SInt; // Add arithmetic traits as needed.
12 macro_rules! fxp_storage_impls {
13 ($($($n:literal)|+ => $sint:ty),* $(,)?) => {
14 $($(impl FxpStorage for PhantomU8<$n> {
25 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 => i128,
28 type FxpStorageHelper<const INT_BITS: u8, const FRAC_BITS: u8> =
29 PhantomU8<{(INT_BITS + FRAC_BITS + 7) / 8}>;
30 //[min]~^ ERROR generic parameters may not be used in const operations
31 //[min]~| ERROR generic parameters may not be used in const operations
33 struct Fxp<const INT_BITS: u8, const FRAC_BITS: u8>
35 FxpStorageHelper<INT_BITS, FRAC_BITS>: FxpStorage,
36 //[full]~^ ERROR constant expression depends on a generic parameter
38 storage: <FxpStorageHelper<INT_BITS, FRAC_BITS> as FxpStorage>::SInt,
42 Fxp::<1, 15> { storage: 0i16 };
43 Fxp::<2, 15> { storage: 0i32 };