1 #![warn(clippy::bool_assert_comparison)]
16 // Implements the Not trait but with an output type
17 // that's not bool. Should not suggest a rewrite
19 enum ImplNotTraitWithoutBool {
24 impl PartialEq<bool> for ImplNotTraitWithoutBool {
25 fn eq(&self, other: &bool) -> bool {
27 ImplNotTraitWithoutBool::VariantX(b) => b == *other,
33 impl Not for ImplNotTraitWithoutBool {
36 fn not(self) -> Self::Output {
38 ImplNotTraitWithoutBool::VariantX(b) => ImplNotTraitWithoutBool::VariantX(!b),
39 ImplNotTraitWithoutBool::VariantY(0) => ImplNotTraitWithoutBool::VariantY(1),
40 ImplNotTraitWithoutBool::VariantY(_) => ImplNotTraitWithoutBool::VariantY(0),
45 // This type implements the Not trait with an Output of
46 // type bool. Using assert!(..) must be suggested
48 struct ImplNotTraitWithBool;
50 impl PartialEq<bool> for ImplNotTraitWithBool {
51 fn eq(&self, other: &bool) -> bool {
56 impl Not for ImplNotTraitWithBool {
59 fn not(self) -> Self::Output {
65 let a = ImplNotTraitWithoutBool::VariantX(true);
66 let b = ImplNotTraitWithBool;
68 assert_eq!("a".len(), 1);
69 assert_eq!("a".is_empty(), false);
70 assert_eq!("".is_empty(), true);
71 assert_eq!(true, "".is_empty());
72 assert_eq!(a!(), b!());
73 assert_eq!(a!(), "".is_empty());
74 assert_eq!("".is_empty(), b!());
78 assert_ne!("a".len(), 1);
79 assert_ne!("a".is_empty(), false);
80 assert_ne!("".is_empty(), true);
81 assert_ne!(true, "".is_empty());
82 assert_ne!(a!(), b!());
83 assert_ne!(a!(), "".is_empty());
84 assert_ne!("".is_empty(), b!());
88 debug_assert_eq!("a".len(), 1);
89 debug_assert_eq!("a".is_empty(), false);
90 debug_assert_eq!("".is_empty(), true);
91 debug_assert_eq!(true, "".is_empty());
92 debug_assert_eq!(a!(), b!());
93 debug_assert_eq!(a!(), "".is_empty());
94 debug_assert_eq!("".is_empty(), b!());
95 debug_assert_eq!(a, true);
96 debug_assert_eq!(b, true);
98 debug_assert_ne!("a".len(), 1);
99 debug_assert_ne!("a".is_empty(), false);
100 debug_assert_ne!("".is_empty(), true);
101 debug_assert_ne!(true, "".is_empty());
102 debug_assert_ne!(a!(), b!());
103 debug_assert_ne!(a!(), "".is_empty());
104 debug_assert_ne!("".is_empty(), b!());
105 debug_assert_ne!(a, true);
106 debug_assert_ne!(b, true);
108 // assert with error messages
109 assert_eq!("a".len(), 1, "tadam {}", 1);
110 assert_eq!("a".len(), 1, "tadam {}", true);
111 assert_eq!("a".is_empty(), false, "tadam {}", 1);
112 assert_eq!("a".is_empty(), false, "tadam {}", true);
113 assert_eq!(false, "a".is_empty(), "tadam {}", true);
114 assert_eq!(a, true, "tadam {}", false);
116 debug_assert_eq!("a".len(), 1, "tadam {}", 1);
117 debug_assert_eq!("a".len(), 1, "tadam {}", true);
118 debug_assert_eq!("a".is_empty(), false, "tadam {}", 1);
119 debug_assert_eq!("a".is_empty(), false, "tadam {}", true);
120 debug_assert_eq!(false, "a".is_empty(), "tadam {}", true);
121 debug_assert_eq!(a, true, "tadam {}", false);