1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
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),
})
}
}