Skip to content

Rust duration conversion and formatting

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT
Notifications You must be signed in to change notification settings

torkleyy/floating-duration

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

floating-duration

Build Status Crates.io MIT/Apache Docs.rs

Allows converting a Duration to floating-point seconds, milliseconds and microseconds. Additionally, it allows automatic formatting of a Duration (it automatically chooses a unit).

Usage

Minimum Rust version: 1.8.0

Add this crate to Cargo.toml

[dependencies]
floating-duration = "0.1.2"

Now you can easily print a Duration:

extern crate floating_duration;

use std::time::Instant;

use floating_duration::{TimeAsFloat, TimeFormat};

fn main() {
    let start = Instant::now();
    
    let result = (1..12).fold(1, |acc, x| acc * x);
    
    println!("Needed {}", TimeFormat(start.elapsed()));
    println!("In seconds: {}", start.elapsed().as_fractional_secs());
}

Contribution

Contribution is very welcome!

Any contribution you submit is assumed to be dual-licensed under MIT/Apache-2.

License

floating-duration is distributed under the terms of both the MIT license and the Apache License (Version 2.0).

See LICENSE-APACHE and LICENSE-MIT.

About

Rust duration conversion and formatting

Topics

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages