Trait DurationExt

Source
pub trait DurationExt {
    // Required method
    fn as_time(&self) -> Time;
}
Expand description

Extension trait for ergonomic operations on Duration.

This trait provides additional utilities for working with std::time::Duration, such as unit-aware conversions and other common operations involving time.

While it currently defines only a single method, it is expected to grow into a collection of Duration-related functionality as the need arises.

§Example

use std::time::Duration;

use twine_core::DurationExt;
use uom::si::{f64::Time, time::second};

let dt = Duration::from_secs_f64(2.5);
let t: Time = dt.as_time();

assert_eq!(t.get::<second>(), 2.5);

Required Methods§

Source

fn as_time(&self) -> Time

Converts this Duration into a uom::si::f64::Time quantity.

Implementations on Foreign Types§

Source§

impl DurationExt for Duration

Source§

fn as_time(&self) -> Time

Implementors§