1pub fn eq<T>(expected: T) -> impl Fn(T) -> bool
2where
3 T: PartialEq,
4{
5 move |actual: T| expected == actual
6}
7
8pub fn ne<T>(expected: T) -> impl Fn(T) -> bool
9where
10 T: PartialEq,
11{
12 move |actual: T| expected != actual
13}
14
15pub fn ge<T>(expected: T) -> impl Fn(T) -> bool
16where
17 T: PartialOrd,
18{
19 move |actual: T| actual >= expected
20}
21
22pub fn gt<T>(expected: T) -> impl Fn(T) -> bool
23where
24 T: PartialOrd,
25{
26 move |actual: T| actual > expected
27}
28
29pub fn le<T>(expected: T) -> impl Fn(T) -> bool
30where
31 T: PartialOrd,
32{
33 move |actual: T| actual <= expected
34}
35
36pub fn lt<T>(expected: T) -> impl Fn(T) -> bool
37where
38 T: PartialOrd,
39{
40 move |actual: T| actual < expected
41}
42
43pub fn and<T>(a: impl Fn(T) -> bool, b: impl Fn(T) -> bool) -> impl Fn(T) -> bool
44where
45 T: Clone,
46{
47 move |actual: T| a(actual.clone()) && b(actual)
48}
49
50pub fn or<T>(a: impl Fn(T) -> bool, b: impl Fn(T) -> bool) -> impl Fn(T) -> bool
51where
52 T: Clone,
53{
54 move |actual: T| a(actual.clone()) || b(actual)
55}
56
57pub fn not<T>(a: impl Fn(T) -> bool) -> impl Fn(T) -> bool
58where
59 T: Sized,
60{
61 move |actual: T| !a(actual)
62}
63
64pub fn contains<T>(needle: T) -> impl Fn(T) -> bool
65where
66 T: AsRef<[u8]>,
67{
68 let needle = String::from_utf8_lossy(needle.as_ref()).to_string();
69 move |actual: T| String::from_utf8_lossy(actual.as_ref()).contains(&needle)
70}