kani/
arbitrary.rs

1// Copyright Kani Contributors
2// SPDX-License-Identifier: Apache-2.0 OR MIT
3
4//! This module introduces the `Arbitrary` trait as well as implementation for
5//! primitive types and other std containers.
6
7use crate::Arbitrary;
8
9impl<T> Arbitrary for std::boxed::Box<T>
10where
11    T: Arbitrary,
12{
13    fn any() -> Self {
14        Box::new(T::any())
15    }
16}
17
18impl Arbitrary for std::time::Duration {
19    fn any() -> Self {
20        const NANOS_PER_SEC: u32 = 1_000_000_000;
21        let nanos = u32::any();
22        crate::assume(nanos < NANOS_PER_SEC);
23        std::time::Duration::new(u64::any(), nanos)
24    }
25}