use crate::{
MatchType::{self, ToBe},
Matcher, TypedMatcher,
};
pub fn some<T>() -> impl TypedMatcher<Option<T>> {
IsSome
}
pub struct IsSome;
impl<T> Matcher<Option<T>> for IsSome {
fn matches(&self, value: &Option<T>) -> bool {
value.is_some()
}
fn description(&self) -> String {
"some".to_string()
}
}
impl<T> TypedMatcher<Option<T>> for IsSome {
fn matcher_type(&self) -> MatchType {
ToBe
}
}
pub fn none<T>() -> impl TypedMatcher<Option<T>> {
IsNone
}
pub struct IsNone;
impl<T> Matcher<Option<T>> for IsNone {
fn matches(&self, value: &Option<T>) -> bool {
value.is_none()
}
fn description(&self) -> String {
"none".to_string()
}
}
impl<T> TypedMatcher<Option<T>> for IsNone {
fn matcher_type(&self) -> MatchType {
ToBe
}
}