[][src]Crate tarde

TARDE (tar-dee, Time And Rust Duration Ergonomics A simple wrapper to '{integer}' types that improves ergonomics around std::time::Duration

Example:

use std::time::{Instant, Duration};
use std::thread;
use tarde::*;

// Before:
fn std_way() {
    let x: u64 = 10;
    let now = Instant::now();
    thread::sleep(Duration::from_millis(2569));

    assert!(now.elapsed() >= Duration::from_millis(x));
}
 
// After:
fn main() -> Result<(), Error> {
   let x = 10;
   let now = Instant::now();
   thread::sleep(x.millis()?); 

   Ok(assert!(now.elapsed() >= x.millis()?))
}

Enums

Error

Using snafu for custom error enum This enum Error contains two types; Convert, and OverFlow

Traits

During

During is the trait we are implementing over Rust primitives During implements converting primitives to micros, millis, nanos, and secs for Duration initialization.