Use Display instead of a custom method

This commit is contained in:
Kirill Bulatov 2020-03-16 12:03:43 +02:00
parent 059ed25a3e
commit 92fd430dab
3 changed files with 17 additions and 19 deletions

View file

@ -14,6 +14,7 @@ use rustc_hash::FxHashMap;
use rustc_hash::FxHashSet;
use crate::{RelativePath, RelativePathBuf};
use fmt::Display;
/// `FileId` is an integer which uniquely identifies a file. File paths are
/// messy and system-dependent, so most of the code should work directly with
@ -102,9 +103,11 @@ impl CrateName {
pub fn normalize_dashes(name: &str) -> CrateName {
Self(SmolStr::new(name.replace('-', "_")))
}
}
pub fn get_name(&self) -> String {
self.0.to_string()
impl Display for CrateName {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.0)
}
}