Skip to content

Commit b72b841

Browse files
committed
Hide shards and determine_map behind the raw-api feature.
1 parent 3021d1a commit b72b841

File tree

3 files changed

+20
-6
lines changed

3 files changed

+20
-6
lines changed

Cargo.toml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "dashmap"
3-
version = "3.0.2"
3+
version = "3.0.3"
44
authors = ["Acrimon <[email protected]>"]
55
edition = "2018"
66
license = "MIT"
@@ -14,6 +14,7 @@ categories = ["concurrency", "algorithms", "data-structures"]
1414

1515
[features]
1616
nightly = ["parking_lot/nightly"]
17+
raw-api = []
1718

1819
[dev-dependencies]
1920
criterion = "0.3.0"
@@ -46,4 +47,8 @@ harness = false
4647
parking_lot = "0.10.0"
4748
num_cpus = "1.11.1"
4849
fxhash = "0.2.1"
49-
serde = { version = "~1.0.24", optional = true, features = ["derive"] }
50+
serde = { version = "1.0.104", optional = true, features = ["derive"] }
51+
cfg-if = "0.1.10"
52+
53+
[package.metadata.docs.rs]
54+
all-features = true

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ If you have any suggestions or tips do not hesitate to open an issue or a PR.
2424

2525
- `serde` - Enables serde support.
2626

27+
- `raw-api` - Enables the unstable raw-shard api.
28+
2729
## Contributing
2830

2931
DashMap is gladly accepts contributions!

src/lib.rs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ use std::iter::FromIterator;
1919
use std::ops::{BitAnd, BitOr, Shl, Shr, Sub};
2020
use t::Map;
2121
use util::SharedValue;
22+
use cfg_if::cfg_if;
2223

2324
type HashMap<K, V> = std::collections::HashMap<K, SharedValue<V>, FxBuildHasher>;
2425

@@ -114,9 +115,13 @@ impl<'a, K: 'a + Eq + Hash, V: 'a> DashMap<K, V> {
114115
/// let map = DashMap::<(), ()>::new();
115116
/// println!("Amount of shards: {}", map.shards().len());
116117
/// ```
117-
#[inline]
118-
pub fn shards(&self) -> &[RwLock<HashMap<K, V>>] {
119-
&self.shards
118+
cfg_if! {
119+
if #[cfg(feature = "raw-api")] {
120+
#[inline]
121+
pub fn shards(&self) -> &[RwLock<HashMap<K, V>>] {
122+
&self.shards
123+
}
124+
}
120125
}
121126

122127
/// Finds which shard a certain key is stored in.
@@ -132,7 +137,9 @@ impl<'a, K: 'a + Eq + Hash, V: 'a> DashMap<K, V> {
132137
/// println!("coca-cola is stored in shard: {}", map.determine_map("coca-cola"));
133138
/// ```
134139
#[inline]
135-
pub fn determine_map<Q>(&self, key: &Q) -> usize
140+
cfg_if! {
141+
if #[cfg(feature = "raw-api")] { pub }
142+
} fn determine_map<Q>(&self, key: &Q) -> usize
136143
where
137144
K: Borrow<Q>,
138145
Q: Hash + Eq + ?Sized,

0 commit comments

Comments
 (0)