mod left_element;
mod should_impl;
pub use left_element::LeftElement;
pub use should_impl::ShouldImpl;
use super::display::PrintDebug;
use super::information::Information;
use std::fmt::Debug;
use std::ops::Not;
pub trait ShouldExtension<L: Debug> {
fn should(self) -> Should<L>;
}
#[derive(Debug)]
#[must_use]
pub struct Should<L>(pub(crate) ShouldImpl<L>)
where
L: Debug;
impl<L> Default for Should<L>
where
L: Debug,
{
fn default() -> Self {
Should(Default::default())
}
}
impl<L> Not for Should<L>
where
L: Debug,
{
type Output = Self;
fn not(self) -> Self {
let ShouldImpl {
left,
truthness,
info,
} = self.0;
Should(ShouldImpl {
truthness: truthness.not(),
left,
info,
})
}
}
impl<L: Debug> ShouldExtension<L> for L {
fn should(self) -> Should<L> {
let left_dbg = self.dbg().to_string();
Should(ShouldImpl {
left: Some(self),
truthness: true,
info: Information::new(None, left_dbg),
})
}
}