diff options
| author | sodiboo <git@sodi.boo> | 2025-01-12 19:22:48 +0100 |
|---|---|---|
| committer | Ivan Molodetskikh <yalterz@gmail.com> | 2025-01-12 21:38:51 +0300 |
| commit | 6e41220dbfa0c7d6291f669a842dde2b562e383b (patch) | |
| tree | 8cb2f72d4f01fb1111ad06d1380aa6ef1ae5f838 /src/utils | |
| parent | e05bc269e678ecf828b96ae79c991c13b00b38a5 (diff) | |
| download | niri-6e41220dbfa0c7d6291f669a842dde2b562e383b.tar.gz niri-6e41220dbfa0c7d6291f669a842dde2b562e383b.tar.bz2 niri-6e41220dbfa0c7d6291f669a842dde2b562e383b.zip | |
use standard padding syntax instead of implementing our own
the padding of the two-digit-month can be implemented much more
concisely using `std::fmt` syntax.
Diffstat (limited to 'src/utils')
| -rw-r--r-- | src/utils/mod.rs | 11 |
1 files changed, 2 insertions, 9 deletions
diff --git a/src/utils/mod.rs b/src/utils/mod.rs index b213205b..0168b83f 100644 --- a/src/utils/mod.rs +++ b/src/utils/mod.rs @@ -87,20 +87,13 @@ pub fn version() -> String { const MINOR: &str = env!("CARGO_PKG_VERSION_MINOR"); const PATCH: &str = env!("CARGO_PKG_VERSION_PATCH"); - let minor_prefix = if MINOR.len() == 1 { - // Print single-digit months in '0M' format. - "0" - } else { - "" - }; - let commit = option_env!("NIRI_BUILD_COMMIT").unwrap_or(git_version!(fallback = "unknown commit")); if PATCH == "0" { - format!("{MAJOR}.{minor_prefix}{MINOR} ({commit})") + format!("{MAJOR}.{MINOR:0>2} ({commit})") } else { - format!("{MAJOR}.{minor_prefix}{MINOR}.{PATCH} ({commit})") + format!("{MAJOR}.{MINOR:0>2}.{PATCH} ({commit})") } } |
