mirror of
https://github.com/niri-wm/niri.git
synced 2026-06-21 02:01:55 +07:00
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.
This commit is contained in:
committed by
Ivan Molodetskikh
parent
e05bc269e6
commit
6e41220dbf
+2
-9
@@ -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})")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user