Skip to content

Commit

Permalink
Fix missing Display impl for TimeDelta
Browse files Browse the repository at this point in the history
  • Loading branch information
algesten committed Jan 24, 2025
1 parent d433ab4 commit c3c480a
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/packet/bwe/time.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use std::cmp::Ordering;
use std::fmt;
use std::ops::{Add, AddAssign, Div, Neg as _, Sub, SubAssign};
use std::time::{Duration, Instant};

Expand Down Expand Up @@ -322,6 +323,17 @@ impl Div<TimeDelta> for DataSize {
}
}

impl fmt::Display for TimeDelta {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
TimeDelta::NegativeInfinity => write!(f, "-Inf"),
TimeDelta::Negative(v) => write!(f, "-{:.03}", v.as_secs_f32()),
TimeDelta::Positive(v) => write!(f, "{:.03}", v.as_secs_f32()),
TimeDelta::PositiveInfinity => write!(f, "+Inf"),
}
}
}

#[cfg(test)]
mod test {
use super::*;
Expand Down

0 comments on commit c3c480a

Please sign in to comment.