diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2018-09-13 19:06:04 +0200 |
|---|---|---|
| committer | Matthias Krüger <matthias.krueger@famsik.de> | 2018-09-13 19:06:04 +0200 |
| commit | 19802f86526442759e4fd3784e94f92d3c1b74bf (patch) | |
| tree | d72814eb5f2606974f3f082138d3bef5880087ea /rustc_tools_util | |
| parent | e8400061bd813fa768e94534028c875ee2c9fe89 (diff) | |
| download | rust-19802f86526442759e4fd3784e94f92d3c1b74bf.tar.gz rust-19802f86526442759e4fd3784e94f92d3c1b74bf.zip | |
rustc_tools_util: clean up pedantic clippy warnings
Diffstat (limited to 'rustc_tools_util')
| -rw-r--r-- | rustc_tools_util/src/lib.rs | 58 |
1 files changed, 27 insertions, 31 deletions
diff --git a/rustc_tools_util/src/lib.rs b/rustc_tools_util/src/lib.rs index 33e1d979dce..bbe86be3c7c 100644 --- a/rustc_tools_util/src/lib.rs +++ b/rustc_tools_util/src/lib.rs @@ -39,48 +39,44 @@ pub struct VersionInfo { } impl std::fmt::Display for VersionInfo { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - match self.commit_hash { - Some(_) => { - write!( - f, - "{} {}.{}.{} ({} {})", - self.crate_name, - self.major, - self.minor, - self.patch, - self.commit_hash.clone().unwrap_or_default().trim(), - self.commit_date.clone().unwrap_or_default().trim(), - )?; - }, - None => { - write!(f, "{} {}.{}.{}", self.crate_name, self.major, self.minor, self.patch)?; - }, - }; + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + if self.commit_hash.is_some() { + write!( + f, + "{} {}.{}.{} ({} {})", + self.crate_name, + self.major, + self.minor, + self.patch, + self.commit_hash.clone().unwrap_or_default().trim(), + self.commit_date.clone().unwrap_or_default().trim(), + )?; + } else { + write!(f, "{} {}.{}.{}", self.crate_name, self.major, self.minor, self.patch)?; + } + Ok(()) } } impl std::fmt::Debug for VersionInfo { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { write!( f, "VersionInfo {{ crate_name: \"{}\", major: {}, minor: {}, patch: {}", self.crate_name, self.major, self.minor, self.patch, )?; - match self.commit_hash { - Some(_) => { - write!( - f, - ", commit_hash: \"{}\", commit_date: \"{}\" }}", - self.commit_hash.clone().unwrap_or_default().trim(), - self.commit_date.clone().unwrap_or_default().trim() - )?; - }, - None => { - write!(f, " }}")?; - }, + if self.commit_hash.is_some() { + write!( + f, + ", commit_hash: \"{}\", commit_date: \"{}\" }}", + self.commit_hash.clone().unwrap_or_default().trim(), + self.commit_date.clone().unwrap_or_default().trim() + )?; + } else { + write!(f, " }}")?; } + Ok(()) } } |
