From a85c4280bf7af3ea25c34c0cd72d05c8de17454d Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 20 Oct 2020 16:00:51 +0200 Subject: Introduce CrateDisplayName --- crates/base_db/src/input.rs | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'crates/base_db') diff --git a/crates/base_db/src/input.rs b/crates/base_db/src/input.rs index eb3aac88d..02c7348ff 100644 --- a/crates/base_db/src/input.rs +++ b/crates/base_db/src/input.rs @@ -102,7 +102,29 @@ impl fmt::Display for CrateName { impl ops::Deref for CrateName { type Target = str; - fn deref(&self) -> &Self::Target { + fn deref(&self) -> &str { + &*self.0 + } +} + +#[derive(Debug, Clone, PartialEq, Eq, Hash)] +pub struct CrateDisplayName(CrateName); + +impl From for CrateDisplayName { + fn from(inner: CrateName) -> CrateDisplayName { + CrateDisplayName(inner) + } +} + +impl fmt::Display for CrateDisplayName { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "{}", self.0) + } +} + +impl ops::Deref for CrateDisplayName { + type Target = str; + fn deref(&self) -> &str { &*self.0 } } -- cgit v1.2.3