diff options
author | Aleksey Kladov <[email protected]> | 2020-10-20 15:00:51 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2020-10-20 15:00:51 +0100 |
commit | a85c4280bf7af3ea25c34c0cd72d05c8de17454d (patch) | |
tree | f54e5fb19a3b4b0981454f33266da8003197cb97 /crates | |
parent | af4e75533f2c071330e740e2fa94b131e3a2b538 (diff) |
Introduce CrateDisplayName
Diffstat (limited to 'crates')
-rw-r--r-- | crates/base_db/src/input.rs | 24 |
1 files changed, 23 insertions, 1 deletions
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 { | |||
102 | 102 | ||
103 | impl ops::Deref for CrateName { | 103 | impl ops::Deref for CrateName { |
104 | type Target = str; | 104 | type Target = str; |
105 | fn deref(&self) -> &Self::Target { | 105 | fn deref(&self) -> &str { |
106 | &*self.0 | ||
107 | } | ||
108 | } | ||
109 | |||
110 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
111 | pub struct CrateDisplayName(CrateName); | ||
112 | |||
113 | impl From<CrateName> for CrateDisplayName { | ||
114 | fn from(inner: CrateName) -> CrateDisplayName { | ||
115 | CrateDisplayName(inner) | ||
116 | } | ||
117 | } | ||
118 | |||
119 | impl fmt::Display for CrateDisplayName { | ||
120 | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { | ||
121 | write!(f, "{}", self.0) | ||
122 | } | ||
123 | } | ||
124 | |||
125 | impl ops::Deref for CrateDisplayName { | ||
126 | type Target = str; | ||
127 | fn deref(&self) -> &str { | ||
106 | &*self.0 | 128 | &*self.0 |
107 | } | 129 | } |
108 | } | 130 | } |