use crate::{
MatchType::{self, ToBe},
Matcher, TypedMatcher,
};
pub fn ok<T, E>() -> impl TypedMatcher<Result<T, E>> {
IsOk
}
pub struct IsOk;
impl<T, E> Matcher<Result<T, E>> for IsOk {
fn matches(&self, value: &Result<T, E>) -> bool {
value.is_ok()
}
fn description(&self) -> String {
"ok".to_string()
}
}
impl<T, E> TypedMatcher<Result<T, E>> for IsOk {
fn matcher_type(&self) -> MatchType {
ToBe
}
}
pub fn err<T, E>() -> impl TypedMatcher<Result<T, E>> {
IsErr
}
pub struct IsErr;
impl<T, E> Matcher<Result<T, E>> for IsErr {
fn matches(&self, value: &Result<T, E>) -> bool {
value.is_err()
}
fn description(&self) -> String {
"err".to_string()
}
}
impl<T, E> TypedMatcher<Result<T, E>> for IsErr {
fn matcher_type(&self) -> MatchType {
ToBe
}
}