Expand description
This library provides a way to handle constant and non-constant values in a unified way. This library takes both flexibilities to take dynamic values and (partial) parameter checking by the compiler.
§Example
fn maybe_one<T: partial_const::MayBeConst<i32>>(i: T) -> bool
where T: partial_const::Equals<partial_const::ConstI32<1>> {
// where T: partial_const::Equals<partial_const::i32::Const<1>> { <- Alternative
i.value() == 1i32
}
assert!(maybe_one(partial_const::ConstI32::<1>::new()));
assert!(maybe_one::<partial_const::ConstI32<1>>(partial_const::ConstI32::new()));
assert!(maybe_one::<i32>(1));
assert!(!maybe_one::<i32>(2));
// assert!(maybe_one(partial_const::ConstI32::<2>::new())); <- Compile Error
Modules§
- bool
- module for bool
- char
- module for char
- i8
- module for i8
- i16
- module for i16
- i32
- module for i32
- i64
- module for i64
- i128
- module for i128
- isize
- module for isize
- u8
- module for u8
- u16
- module for u16
- u32
- module for u32
- u64
- module for u64
- u128
- module for u128
- usize
- module for usize
Traits§
- Equals
- A trait for putting equality constraints on constants. It will be implemented if the constants are equal.
- MayBe
Const - A trait for handling constant and non-constant values in a common way
- MayBe
ConstAT - A trait MayBeConst by associated type for internal trait bounds.
Type Aliases§
- Const
Bool - See bool::Const
- Const
Char - See char::Const
- ConstI8
- See i8::Const
- Const
I16 - See i16::Const
- Const
I32 - See i32::Const
- Const
I64 - See i64::Const
- Const
I128 - See i128::Const
- Const
Isize - See isize::Const
- ConstU8
- See u8::Const
- Const
U16 - See u16::Const
- Const
U32 - See u32::Const
- Const
U64 - See u64::Const
- Const
U128 - See u128::Const
- Const
Usize - See usize::Const