1use super::*;
8use crate::math::One;
9use crate::prelude::*;
10
11pub struct Counted<'a, T> {
13 pub count: T,
14 pub one: &'a str,
15 pub many: &'a str,
16}
17
18pub fn count<'a, T>(count: T, one: &'a str, many: &'a str) -> Counted<'a, T> {
20 Counted { count, one, many }
21}
22
23impl<'a, T> Display for Counted<'a, T>
24where
25 T: Display + One + PartialEq,
26{
27 fn fmt(&self, f: &mut Formatter) -> fmt::Result {
28 Display::fmt(&self.count, f)?;
29
30 match self.count.is_one() {
31 true => write!(f, " {}", self.one),
32 false => write!(f, " {}", self.many),
33 }
34 }
35}