time: also implement From<&TimeSpan> for f64
Extend the already present `From<TimeSpan> for f64` implementation to allow using the reference as well. There is no need to take ownership and consume the `TimeSpan` object for conversion. Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
This commit is contained in:
parent
548411808e
commit
17bc0ac616
@ -128,8 +128,8 @@ pub struct TimeSpan {
|
||||
pub years: u64,
|
||||
}
|
||||
|
||||
impl From<TimeSpan> for f64 {
|
||||
fn from(ts: TimeSpan) -> Self {
|
||||
impl From<&TimeSpan> for f64 {
|
||||
fn from(ts: &TimeSpan) -> Self {
|
||||
(ts.seconds as f64)
|
||||
+ ((ts.nsec as f64) / 1_000_000_000.0)
|
||||
+ ((ts.usec as f64) / 1_000_000.0)
|
||||
@ -143,6 +143,12 @@ impl From<TimeSpan> for f64 {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<TimeSpan> for f64 {
|
||||
fn from(ts: TimeSpan) -> Self {
|
||||
Self::from(&ts)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<std::time::Duration> for TimeSpan {
|
||||
fn from(duration: std::time::Duration) -> Self {
|
||||
let mut duration = duration.as_nanos();
|
||||
|
Loading…
x
Reference in New Issue
Block a user