diff --git a/Cargo.toml b/Cargo.toml index a38df928..c5c93b65 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "dashmap" -version = "3.0.2" +version = "3.0.3" authors = ["Acrimon "] edition = "2018" license = "MIT" @@ -14,6 +14,7 @@ categories = ["concurrency", "algorithms", "data-structures"] [features] nightly = ["parking_lot/nightly"] +raw-api = [] [dev-dependencies] criterion = "0.3.0" @@ -46,4 +47,8 @@ harness = false parking_lot = "0.10.0" num_cpus = "1.11.1" fxhash = "0.2.1" -serde = { version = "~1.0.24", optional = true, features = ["derive"] } +serde = { version = "1.0.104", optional = true, features = ["derive"] } +cfg-if = "0.1.10" + +[package.metadata.docs.rs] +all-features = true diff --git a/README.md b/README.md index b3968caf..fccca456 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,8 @@ If you have any suggestions or tips do not hesitate to open an issue or a PR. - `serde` - Enables serde support. +- `raw-api` - Enables the unstable raw-shard api. + ## Contributing DashMap is gladly accepts contributions! diff --git a/src/lib.rs b/src/lib.rs index 714ee50f..85fbbeb0 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -19,6 +19,7 @@ use std::iter::FromIterator; use std::ops::{BitAnd, BitOr, Shl, Shr, Sub}; use t::Map; use util::SharedValue; +use cfg_if::cfg_if; type HashMap = std::collections::HashMap, FxBuildHasher>; @@ -114,9 +115,13 @@ impl<'a, K: 'a + Eq + Hash, V: 'a> DashMap { /// let map = DashMap::<(), ()>::new(); /// println!("Amount of shards: {}", map.shards().len()); /// ``` - #[inline] - pub fn shards(&self) -> &[RwLock>] { - &self.shards + cfg_if! { + if #[cfg(feature = "raw-api")] { + #[inline] + pub fn shards(&self) -> &[RwLock>] { + &self.shards + } + } } /// Finds which shard a certain key is stored in. @@ -132,7 +137,9 @@ impl<'a, K: 'a + Eq + Hash, V: 'a> DashMap { /// println!("coca-cola is stored in shard: {}", map.determine_map("coca-cola")); /// ``` #[inline] - pub fn determine_map(&self, key: &Q) -> usize + cfg_if! { + if #[cfg(feature = "raw-api")] { pub } + } fn determine_map(&self, key: &Q) -> usize where K: Borrow, Q: Hash + Eq + ?Sized,