Skip to content

Commit

Permalink
add support for arbitrary (#272)
Browse files Browse the repository at this point in the history
  • Loading branch information
xacrimon committed Jul 11, 2023
1 parent d36311e commit 4c7568c
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ serde = { version = "1.0.171", optional = true, features = ["derive"] }
cfg-if = "1.0.0"
rayon = { version = "1.7.0", optional = true }
once_cell = "1.18.0"
arbitrary = { version = "1.3.0", optional = true }

[package.metadata.docs.rs]
features = ["rayon", "raw-api", "serde"]
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

- `arbitrary` - Enables support for the `arbitrary` crate.

## Contributing

DashMap gladly accepts contributions!
Expand Down
13 changes: 13 additions & 0 deletions src/arbitrary.rs
Original file line number Diff line number Diff line change
@@ -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()
}
}
2 changes: 2 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#![allow(clippy::type_complexity)]

#[cfg(feature = "arbitrary")]
mod arbitrary;
pub mod iter;
pub mod iter_set;
mod lock;
Expand Down

0 comments on commit 4c7568c

Please sign in to comment.