just-lsp 0.3.0

A language server for just
use super::*;

pub(crate) struct Count<T: Display>(pub(crate) T, pub(crate) usize);

impl<T: Display> Display for Count<T> {
  fn fmt(&self, f: &mut Formatter) -> fmt::Result {
    if self.1 == 1 {
      write!(f, "{}", self.0)
    } else {
      write!(f, "{}s", self.0)
    }
  }
}

#[cfg(test)]
mod tests {
  use super::*;

  #[test]
  fn count() {
    assert_eq!(Count("dog", 0).to_string(), "dogs");
    assert_eq!(Count("dog", 1).to_string(), "dog");
    assert_eq!(Count("dog", 2).to_string(), "dogs");
  }
}