Trait memsecurity::MinMaxNum
source · pub trait MinMaxNum: PartialOrd + Add + Sub + Copy {
const MIN_VALUE: Self;
const MAX_VALUE: Self;
}Expand description
Define maximum number a generic T can hold.
This is implemented for all integer and float primitive types
Example
// The function with the enforced constraint
fn foo<T: MustBeInRange>(bar: T) {
// Use T as needed
println!("Input: {:?}", bar);
}
foo(42u64);
foo(0u64);
foo(std::u64::MAX);