forge
Explore
Log in

Don't you dare go Hollow

use standard padding syntax instead of implementing our own

Browse files at this commit

6e41220dbfa0c7d6291f669a842dde2b562e383bsodibooParent: e05bc26
the padding of the two-digit-month can be implemented much more
concisely using `std::fmt` syntax.
src/utils/mod.rsmodified+2 -9
@@ -87,20 +87,13 @@ pub fn version() -> String {
87 const MINOR: &str = env!("CARGO_PKG_VERSION_MINOR");87 const MINOR: &str = env!("CARGO_PKG_VERSION_MINOR");
88 const PATCH: &str = env!("CARGO_PKG_VERSION_PATCH");88 const PATCH: &str = env!("CARGO_PKG_VERSION_PATCH");
89 89
90- let minor_prefix = if MINOR.len() == 1 {
91- // Print single-digit months in '0M' format.
92- "0"
93- } else {
94- ""
95- };
96-
97 let commit =90 let commit =
98 option_env!("NIRI_BUILD_COMMIT").unwrap_or(git_version!(fallback = "unknown commit"));91 option_env!("NIRI_BUILD_COMMIT").unwrap_or(git_version!(fallback = "unknown commit"));
99 92
100 if PATCH == "0" {93 if PATCH == "0" {
101- format!("{MAJOR}.{minor_prefix}{MINOR} ({commit})")94+ format!("{MAJOR}.{MINOR:0>2} ({commit})")
102 } else {95 } else {
103- format!("{MAJOR}.{minor_prefix}{MINOR}.{PATCH} ({commit})")96+ format!("{MAJOR}.{MINOR:0>2}.{PATCH} ({commit})")
104 }97 }
105 }98 }
106 99