Implement Display for Version, and use it for Debug too.
Also implement Eq.
Change-Id: I3e03da6ecb8dbab47169ebdf14bd1d50f0a8a3f4
Signed-off-by: Andrew Walbran <qwandor@google.com>
diff --git a/src/lib.rs b/src/lib.rs
index 18dfd19..48b65ea 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -6,6 +6,7 @@
extern crate alloc;
use alloc::string::String;
+use core::fmt::{self, Debug, Display, Formatter};
use num_enum::{IntoPrimitive, TryFromPrimitive};
use thiserror::Error;
use uuid::Uuid;
@@ -828,7 +829,7 @@
}
}
-#[derive(Clone, Copy, Debug, PartialEq)]
+#[derive(Clone, Copy, Eq, PartialEq)]
pub struct Version(pub u16, pub u16);
impl From<u32> for Version {
@@ -843,6 +844,18 @@
}
}
+impl Display for Version {
+ fn fmt(&self, f: &mut Formatter) -> fmt::Result {
+ write!(f, "{}.{}", self.0, self.1)
+ }
+}
+
+impl Debug for Version {
+ fn fmt(&self, f: &mut Formatter) -> fmt::Result {
+ Display::fmt(self, f)
+ }
+}
+
pub fn parse_console_log(
char_cnt: u32,
char_lists: &[u64; 6],