proptest/arbitrary/_alloc/hash.rs
1//-
2// Copyright 2017, 2018 The proptest developers
3//
4// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
5// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
6// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
7// option. This file may not be copied, modified, or distributed
8// except according to those terms.
9
10//! Arbitrary implementations for `std::hash`.
11
12#[cfg(feature = "std")]
13use crate::std_facade::hash_map::{DefaultHasher, RandomState};
14use core::hash::{BuildHasherDefault, Hasher};
15
16// NOTE: don't impl for std::hash::SipHasher.. since deprecated!
17
18// over-constrain on purpose!
19arbitrary!([H: Default + Hasher] BuildHasherDefault<H>; Default::default());
20
21#[cfg(feature = "std")]
22lazy_just!(DefaultHasher, Default::default; RandomState, Default::default);
23
24#[cfg(test)]
25mod test {
26 #[cfg(feature = "std")]
27 no_panic_test!(
28 default_hasher => DefaultHasher,
29 random_state => RandomState,
30 build_hasher_default => BuildHasherDefault<DefaultHasher>
31 );
32}