1use std::fmt;
23/// Error indicating that the number of cells tested (the first
4/// argument) is larger than the bucket's capacity.
5///
6/// This means the decision can never have a conforming result. The
7/// argument gives the maximum number of cells that could ever have a
8/// conforming result.
9#[derive(Debug, Clone, Copy, PartialEq, Eq)]
10pub struct InsufficientCapacity(pub u32);
1112impl fmt::Display for InsufficientCapacity {
13fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
14write!(
15 f,
16"required number of cells {} exceeds bucket's capacity",
17self.0
18)
19 }
20}
2122#[cfg(feature = "std")]
23impl std::error::Error for InsufficientCapacity {}
2425#[cfg(all(feature = "std", test))]
26mod test {
27use super::*;
2829#[test]
30fn coverage() {
31let display_output = format!("{}", InsufficientCapacity(3));
32assert!(display_output.contains("3"));
33let debug_output = format!("{:?}", InsufficientCapacity(3));
34assert!(debug_output.contains("3"));
35assert_eq!(InsufficientCapacity(3), InsufficientCapacity(3));
36 }
37}