// `Self` cannot be used where type takes generic arguments #![allow(clippy::use_self)] use crate::common::*; pub struct Enclosure { enclosure: &'static str, value: T, } impl Enclosure { pub fn tick(value: T) -> Enclosure { Self { enclosure: "`", value, } } } impl Display for Enclosure { 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`") } }