mirror of
https://gitlab.com/veilid/veilid.git
synced 2024-10-01 01:26:08 -04:00
proper display/from_str for timestamp/duration
This commit is contained in:
parent
63b5845a8b
commit
627bbf209e
@ -2,12 +2,7 @@
|
||||
use super::*;
|
||||
|
||||
aligned_u64_type!(Timestamp);
|
||||
|
||||
impl fmt::Display for Timestamp {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(f, "{}", debug_ts(self.as_u64()))
|
||||
}
|
||||
}
|
||||
aligned_u64_type_default_display_impl!(Timestamp);
|
||||
|
||||
impl fmt::Debug for Timestamp {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
|
@ -2,24 +2,12 @@
|
||||
use super::*;
|
||||
|
||||
aligned_u64_type!(TimestampDuration);
|
||||
aligned_u64_type_default_display_impl!(TimestampDuration);
|
||||
aligned_u64_type_default_math_impl!(TimestampDuration);
|
||||
|
||||
impl fmt::Display for TimestampDuration {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
(&self.0 as &dyn fmt::Display).fmt(f)
|
||||
}
|
||||
}
|
||||
|
||||
impl FromStr for TimestampDuration {
|
||||
type Err = <u64 as FromStr>::Err;
|
||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||
Ok(TimestampDuration(u64::from_str(s)?))
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Debug for TimestampDuration {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
(&self.0 as &dyn fmt::Debug).fmt(f)
|
||||
write!(f, "{}", debug_duration(self.as_u64()))
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user