1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#![allow(clippy::use_self)]
use crate::common::*;
pub struct Enclosure<T: Display> {
  enclosure: &'static str,
  value:     T,
}
impl<T: Display> Enclosure<T> {
  pub fn tick(value: T) -> Enclosure<T> {
    Self {
      enclosure: "`",
      value,
    }
  }
}
impl<T: Display> Display for Enclosure<T> {
  fn fmt(&self, f: &mut Formatter) -> fmt::Result {
    write!(f, "{}{}{}", self.enclosure, self.value, self.enclosure)
  }
}
#[cfg(test)]
mod tests {
  use super::*;
  #[test]
  fn tick() {
    assert_eq!(Enclosure::tick("foo").to_string(), "`foo`")
  }
}