|
1 | 1 | //! Predicates based on length. |
2 | 2 |
|
3 | | -use core::fmt; |
| 3 | +use core::{fmt, marker::PhantomData}; |
4 | 4 |
|
5 | 5 | #[cfg(feature = "diagnostics")] |
6 | 6 | use miette::Diagnostic; |
@@ -40,8 +40,9 @@ impl LessError { |
40 | 40 | } |
41 | 41 |
|
42 | 42 | /// Checks whether the given value has length less than `N`. |
43 | | -#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)] |
44 | | -pub struct Less<const N: usize>; |
| 43 | +pub struct Less<const N: usize> { |
| 44 | + private: PhantomData<()>, |
| 45 | +} |
45 | 46 |
|
46 | 47 | impl<const N: usize, T: HasLength + ?Sized> Predicate<T> for Less<N> { |
47 | 48 | type Error = LessError; |
@@ -88,8 +89,9 @@ impl LessOrEqualError { |
88 | 89 | } |
89 | 90 |
|
90 | 91 | /// Checks whether the given value has length less than or equal to `N`. |
91 | | -#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)] |
92 | | -pub struct LessOrEqual<const N: usize>; |
| 92 | +pub struct LessOrEqual<const N: usize> { |
| 93 | + private: PhantomData<()>, |
| 94 | +} |
93 | 95 |
|
94 | 96 | impl<const N: usize, T: HasLength + ?Sized> Predicate<T> for LessOrEqual<N> { |
95 | 97 | type Error = LessOrEqualError; |
@@ -133,8 +135,9 @@ impl GreaterError { |
133 | 135 | } |
134 | 136 |
|
135 | 137 | /// Checks whether the given value has length greater than `N`. |
136 | | -#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)] |
137 | | -pub struct Greater<const N: usize>; |
| 138 | +pub struct Greater<const N: usize> { |
| 139 | + private: PhantomData<()>, |
| 140 | +} |
138 | 141 |
|
139 | 142 | impl<const N: usize, T: HasLength + ?Sized> Predicate<T> for Greater<N> { |
140 | 143 | type Error = GreaterError; |
@@ -181,8 +184,9 @@ impl GreaterOrEqualError { |
181 | 184 | } |
182 | 185 |
|
183 | 186 | /// Checks whether the given value has length greater than or equal to `N`. |
184 | | -#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)] |
185 | | -pub struct GreaterOrEqual<const N: usize>; |
| 187 | +pub struct GreaterOrEqual<const N: usize> { |
| 188 | + private: PhantomData<()>, |
| 189 | +} |
186 | 190 |
|
187 | 191 | impl<const N: usize, T: HasLength + ?Sized> Predicate<T> for GreaterOrEqual<N> { |
188 | 192 | type Error = GreaterOrEqualError; |
@@ -226,8 +230,9 @@ impl EqualError { |
226 | 230 | } |
227 | 231 |
|
228 | 232 | /// Checks whether the given value has length equal to `N`. |
229 | | -#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)] |
230 | | -pub struct Equal<const N: usize>; |
| 233 | +pub struct Equal<const N: usize> { |
| 234 | + private: PhantomData<()>, |
| 235 | +} |
231 | 236 |
|
232 | 237 | impl<const N: usize, T: HasLength + ?Sized> Predicate<T> for Equal<N> { |
233 | 238 | type Error = EqualError; |
@@ -271,8 +276,9 @@ impl NotEqualError { |
271 | 276 | } |
272 | 277 |
|
273 | 278 | /// Checks whether the given value has length not equal to `N`. |
274 | | -#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)] |
275 | | -pub struct NotEqual<const N: usize>; |
| 279 | +pub struct NotEqual<const N: usize> { |
| 280 | + private: PhantomData<()>, |
| 281 | +} |
276 | 282 |
|
277 | 283 | impl<const N: usize, T: HasLength + ?Sized> Predicate<T> for NotEqual<N> { |
278 | 284 | type Error = NotEqualError; |
@@ -335,8 +341,9 @@ impl ModuloError { |
335 | 341 | } |
336 | 342 |
|
337 | 343 | /// Checks whether the given value length divided by `D` has modulo `M`. |
338 | | -#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Default)] |
339 | | -pub struct Modulo<const D: usize, const M: usize>; |
| 344 | +pub struct Modulo<const D: usize, const M: usize> { |
| 345 | + private: PhantomData<()>, |
| 346 | +} |
340 | 347 |
|
341 | 348 | impl<const D: usize, const M: usize, T: HasLength + ?Sized> Predicate<T> for Modulo<D, M> { |
342 | 349 | type Error = ModuloError; |
|
0 commit comments