mirror of https://github.com/xacrimon/dashmap
add support for arbitrary
This commit is contained in:
parent
d36311e634
commit
a483a4c7d8
|
@ -25,6 +25,7 @@ serde = { version = "1.0.171", optional = true, features = ["derive"] }
|
||||||
cfg-if = "1.0.0"
|
cfg-if = "1.0.0"
|
||||||
rayon = { version = "1.7.0", optional = true }
|
rayon = { version = "1.7.0", optional = true }
|
||||||
once_cell = "1.18.0"
|
once_cell = "1.18.0"
|
||||||
|
arbitrary = { version = "1.3.0", optional = true }
|
||||||
|
|
||||||
[package.metadata.docs.rs]
|
[package.metadata.docs.rs]
|
||||||
features = ["rayon", "raw-api", "serde"]
|
features = ["rayon", "raw-api", "serde"]
|
||||||
|
|
|
@ -32,6 +32,8 @@ If you have any suggestions or tips do not hesitate to open an issue or a PR.
|
||||||
|
|
||||||
- `inline` - Enables `inline-more` feature from the `hashbrown` crate. Can lead to better performance, but with the cost of longer compile-time.
|
- `inline` - Enables `inline-more` feature from the `hashbrown` crate. Can lead to better performance, but with the cost of longer compile-time.
|
||||||
|
|
||||||
|
- `arbitrary` - Enables support for the `arbitrary` crate.
|
||||||
|
|
||||||
## Contributing
|
## Contributing
|
||||||
|
|
||||||
DashMap gladly accepts contributions!
|
DashMap gladly accepts contributions!
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
use arbitrary::{Arbitrary, Unstructured};
|
||||||
|
use core::hash::BuildHasher;
|
||||||
|
|
||||||
|
impl<'a, K, V, S> Arbitrary<'a> for crate::DashMap<K, V, S>
|
||||||
|
where
|
||||||
|
K: Eq + std::hash::Hash + Arbitrary<'a>,
|
||||||
|
V: Arbitrary<'a>,
|
||||||
|
S: Default + BuildHasher + Clone,
|
||||||
|
{
|
||||||
|
fn arbitrary(u: &mut Unstructured<'a>) -> arbitrary::Result<Self> {
|
||||||
|
u.arbitrary_iter()?.collect()
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,5 +1,7 @@
|
||||||
#![allow(clippy::type_complexity)]
|
#![allow(clippy::type_complexity)]
|
||||||
|
|
||||||
|
#[cfg(feature = "arbitrary")]
|
||||||
|
mod arbitrary;
|
||||||
pub mod iter;
|
pub mod iter;
|
||||||
pub mod iter_set;
|
pub mod iter_set;
|
||||||
mod lock;
|
mod lock;
|
||||||
|
|
Loading…
Reference in New Issue