2021-11-14 13:09:14 +00:00
|
|
|
use num_traits::AsPrimitive;
|
|
|
|
|
|
|
|
use crate::{InputType, InputValueError};
|
|
|
|
|
2021-11-15 01:12:13 +00:00
|
|
|
pub fn minimum<T: AsPrimitive<f64> + InputType>(
|
2021-11-14 13:09:14 +00:00
|
|
|
value: &T,
|
|
|
|
n: f64,
|
|
|
|
) -> Result<(), InputValueError<T>> {
|
|
|
|
if value.as_() >= n {
|
|
|
|
Ok(())
|
|
|
|
} else {
|
|
|
|
Err(format!(
|
|
|
|
"the value is {}, must be greater than or equal to {}",
|
|
|
|
value.as_(),
|
|
|
|
n
|
|
|
|
)
|
|
|
|
.into())
|
|
|
|
}
|
|
|
|
}
|