1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#![no_std]
#![doc(test(
no_crate_inject,
attr(
deny(warnings, rust_2018_idioms, single_use_lifetimes),
allow(dead_code, unused_variables)
)
))]
#![forbid(unsafe_code)]
#![warn(future_incompatible, rust_2018_idioms, single_use_lifetimes, unreachable_pub)]
#![warn(missing_debug_implementations, missing_docs)]
#![warn(clippy::all, clippy::default_trait_access)]
#![cfg_attr(docsrs, feature(doc_cfg))]
#[cfg(feature = "std")]
extern crate std;
mod duration;
pub use crate::duration::Duration;
#[cfg(feature = "std")]
mod instant;
#[cfg(feature = "std")]
pub use crate::instant::Instant;
mod error;
pub use crate::error::TryFromTimeError;
#[inline]
fn pair_and_then<A, B, C, F>(x: Option<A>, y: Option<B>, f: F) -> Option<C>
where
F: FnOnce(A, B) -> Option<C>,
{
match (x, y) {
(Some(x), Some(y)) => f(x, y),
_ => None,
}
}
#[cfg(test)]
mod tests {
use static_assertions::assert_impl_all as assert_impl;
use crate::*;
assert_impl!(Duration: Send);
assert_impl!(Duration: Sync);
assert_impl!(Duration: Unpin);
#[cfg(feature = "std")]
assert_impl!(Instant: Send);
#[cfg(feature = "std")]
assert_impl!(Instant: Sync);
#[cfg(feature = "std")]
assert_impl!(Instant: Unpin);
assert_impl!(TryFromTimeError: Send);
assert_impl!(TryFromTimeError: Sync);
assert_impl!(TryFromTimeError: Unpin);
}