diff options
| author | Mason Reed <mason@vector35.com> | 2025-12-07 15:04:02 -0500 |
|---|---|---|
| committer | Mason Reed <35282038+emesare@users.noreply.github.com> | 2025-12-10 17:35:19 -0500 |
| commit | c3b40624916b3f75e9941158b43972e78e3f2a98 (patch) | |
| tree | 20372c72d70b55113c77f6c2cbed6833be55f40c /rust/src | |
| parent | 501fe3ec7a63a534fca3926a5fc4267f6886f089 (diff) | |
[Rust] Impl `Display` for `VersionInfo`
Diffstat (limited to 'rust/src')
| -rw-r--r-- | rust/src/lib.rs | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/rust/src/lib.rs b/rust/src/lib.rs index 50913ed8..ad1d910d 100644 --- a/rust/src/lib.rs +++ b/rust/src/lib.rs @@ -104,6 +104,7 @@ use rc::Ref; use std::cmp; use std::collections::HashMap; use std::ffi::{c_char, c_void, CStr}; +use std::fmt::{Display, Formatter}; use std::path::{Path, PathBuf}; use string::BnString; use string::IntoCStr; @@ -513,6 +514,20 @@ impl Ord for VersionInfo { } } +impl Display for VersionInfo { + fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { + if self.channel.is_empty() { + write!(f, "{}.{}.{}", self.major, self.minor, self.build) + } else { + write!( + f, + "{}.{}.{}-{}", + self.major, self.minor, self.build, self.channel + ) + } + } +} + pub fn version_info() -> VersionInfo { let info_raw = unsafe { BNGetVersionInfo() }; VersionInfo::from_owned_raw(info_raw) |
