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 {
8787 const MINOR: &str = env!("CARGO_PKG_VERSION_MINOR");
8888 const PATCH: &str = env!("CARGO_PKG_VERSION_PATCH");
8989
90- let minor_prefix = if MINOR.len() == 1 {
91- // Print single-digit months in '0M' format.
92- "0"
93- } else {
94- ""
95- };
96-
9790 let commit =
9891 option_env!("NIRI_BUILD_COMMIT").unwrap_or(git_version!(fallback = "unknown commit"));
9992
10093 if PATCH == "0" {
101- format!("{MAJOR}.{minor_prefix}{MINOR} ({commit})")
94+ format!("{MAJOR}.{MINOR:0>2} ({commit})")
10295 } else {
103- format!("{MAJOR}.{minor_prefix}{MINOR}.{PATCH} ({commit})")
96+ format!("{MAJOR}.{MINOR:0>2}.{PATCH} ({commit})")
10497 }
10598 }
10699