diff --git a/src/duration.rs b/src/duration.rs index e2e8559..6dc76f5 100644 --- a/src/duration.rs +++ b/src/duration.rs @@ -47,6 +47,9 @@ impl Duration { // TODO: duration_constants https://github.com/rust-lang/rust/issues/57391 // TODO: div_duration https://github.com/rust-lang/rust/issues/63139 + /// Returns a "none" value + pub const NONE: Self = Self(None); + /// A duration of zero time. /// /// # Examples diff --git a/src/instant.rs b/src/instant.rs index 22d6aef..4ff2ad4 100644 --- a/src/instant.rs +++ b/src/instant.rs @@ -60,6 +60,9 @@ use super::{pair_and_then, Duration, TryFromTimeError}; pub struct Instant(Option); impl Instant { + /// Returns a "none" value + pub const NONE: Self = Self(None); + /// Returns an instant corresponding to "now". /// /// # Examples diff --git a/tests/duration.rs b/tests/duration.rs index 993cd08..e79ea37 100644 --- a/tests/duration.rs +++ b/tests/duration.rs @@ -5,6 +5,11 @@ use core::time; use easytime::Duration; +#[test] +fn none() { + assert!(Duration::NONE.is_none()); +} + #[test] fn cmp() { assert!(Duration::from_secs(1) == Duration::from_secs(1)); diff --git a/tests/instant.rs b/tests/instant.rs index 1a0bcf0..f77ccf5 100644 --- a/tests/instant.rs +++ b/tests/instant.rs @@ -21,6 +21,11 @@ pub mod std_tests { }}; } + #[test] + fn none() { + assert!(Instant::NONE.is_none()); + } + #[test] fn instant_monotonic() { let a = Instant::now();