use crate::Matcher;
use std::fmt::Debug;
pub fn lt<T>(value: T) -> LessThan<T> {
LessThan(value)
}
pub struct LessThan<T>(T);
impl<T> Matcher<T> for LessThan<T>
where
T: PartialOrd + Debug,
{
fn matches(&self, value: &T) -> bool {
*value < self.0
}
fn description(&self) -> String {
format!("less than {:?}", self.0)
}
}
pub fn le<T>(value: T) -> LessThanOrEqual<T> {
LessThanOrEqual(value)
}
pub struct LessThanOrEqual<T>(T);
impl<T> Matcher<T> for LessThanOrEqual<T>
where
T: PartialOrd + Debug,
{
fn matches(&self, value: &T) -> bool {
*value <= self.0
}
fn description(&self) -> String {
format!("less than or equal to {:?}", self.0)
}
}