use crate::{assert_that, Asserter};
impl<AssertedType> Asserter<AssertedType> {
#[track_caller]
#[must_use = "Extracting a value without assertion does nothing"]
pub fn extract<NewAssertedType>(
self,
extractor: impl FnOnce(AssertedType) -> NewAssertedType,
) -> Asserter<NewAssertedType> {
let extracted = extractor(self.value);
assert_that(extracted)
}
}
impl<AssertedType> Asserter<AssertedType>
where
AssertedType: ToString,
{
#[track_caller]
#[must_use = "Transforming the asserted value does not assert anything"]
pub fn to_string(self) -> Asserter<String> {
Asserter {
value: self.value.to_string(),
}
}
}