use crate::{
description::Description,
matcher::{Describable, Matcher, MatcherResult},
};
use std::fmt::Debug;
pub fn anything() -> __internal::AnythingMatcher {
__internal::AnythingMatcher
}
pub mod __internal {
use super::*;
#[doc(hidden)]
pub struct AnythingMatcher;
impl<T: Debug + ?Sized> Matcher<T> for AnythingMatcher {
fn matches(&self, _: &T) -> MatcherResult {
MatcherResult::Match
}
}
impl Describable for AnythingMatcher {
fn describe(&self, matcher_result: MatcherResult) -> Description {
match matcher_result {
MatcherResult::Match => "is anything".into(),
MatcherResult::NoMatch => "never matches".into(),
}
}
}
}
#[cfg(test)]
mod tests {
use super::anything;
use crate::prelude::*;
#[test]
fn anything_matches_i32() -> TestResult<()> {
let value = 32;
verify_that!(value, anything())?;
Ok(())
}
#[test]
fn anything_matches_str() -> TestResult<()> {
let value = "32";
verify_that!(value, anything())?;
Ok(())
}
#[test]
fn anything_matches_option() -> TestResult<()> {
let value = Some(32);
verify_that!(value, some(anything()))?;
Ok(())
}
}