arbitrary/foreign/core/
time.rs
1use {
2 crate::{size_hint, Arbitrary, Result, Unstructured},
3 core::time::Duration,
4};
5
6impl<'a> Arbitrary<'a> for Duration {
7 fn arbitrary(u: &mut Unstructured<'a>) -> Result<Self> {
8 Ok(Self::new(
9 <u64 as Arbitrary>::arbitrary(u)?,
10 u.int_in_range(0..=999_999_999)?,
11 ))
12 }
13
14 #[inline]
15 fn size_hint(depth: usize) -> (usize, Option<usize>) {
16 size_hint::and(
17 <u64 as Arbitrary>::size_hint(depth),
18 <u32 as Arbitrary>::size_hint(depth),
19 )
20 }
21}