Expand description
§Roundable values
This provides an implementation of rounding for various values, including
std::time::Duration.
use roundable::Roundable;
assert!(310 == 314.round_to(10));
assert!(300.0 == 314.1.round_to(100.0));See Constants for a list of time units that make rounding
Duration easier.
use roundable::{SECOND, MINUTE, Roundable};
use std::time::Duration;
assert!(Duration::ZERO == Duration::from_millis(314).round_to(SECOND));
assert!(MINUTE == Duration::from_millis(59_500).round_to(SECOND));§Minimum supported Rust version
Currently the minimum supported Rust version (MSRV) is 1.56.1. Future increases in the MSRV will require a major version bump.
Constants§
- An hour. Useful for rounding
Duration. - A microsecond. Useful for rounding
Duration. - A millisecond. Useful for rounding
Duration. - A minute. Useful for rounding
Duration. - A second. Useful for rounding
Duration.
Traits§
- Add methods to round to an arbitrary factor.
Functions§
- Create a new
Durationfrom au128of nanoseconds.