proptest-arbitrary 0.2.0

The Arbitrary trait for proptest and implementations for the standard library.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use super::*;
use std::time::*;

impl_arbitrary!(Duration, SMapped<'a, (u64, u32), Self>,
    static_map(any::<(u64, u32)>(), |(a, b)| Duration::new(a, b))
);

// Instant::now() "never" returns the same Instant, so no shrinking may occur!
impl_just!(Instant, Instant::now());
// Same for SystemTime.
impl_just!(SystemTime, SystemTime::now());
/*
A possible logic for SystemTimeError:
fn gen_ste() -> SystemTimeError {
    (SystemTime::now() + Duration::from_millis(10)).elapsed().unwrap_err()
}
This may however panic from time to time. NTP could also ruin our day!
*/