Skip to content

Commit 82d6f9d

Browse files
committed
Auto merge of #108 - Amanieu:pub_rawtable, r=Amanieu
Experimentally expose RawTable under the "raw" feature Fixes #104
2 parents 95c19f4 + 5569ef1 commit 82d6f9d

File tree

6 files changed

+29
-8
lines changed

6 files changed

+29
-8
lines changed

.travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ matrix:
1313
- name: "docs"
1414
env: TARGET=x86_64-unknown-linux-gnu
1515
script:
16-
- cargo -vv doc --features nightly,serde,rayon
16+
- cargo -vv doc --features nightly,serde,rayon,raw
1717
- echo '<meta http-equiv=refresh content=0;url=hashbrown/index.html>' > target/doc/index.html
1818
deploy:
1919
provider: pages

Cargo.toml

+4
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,7 @@ default = ["ahash"]
4141
nightly = []
4242
rustc-internal-api = []
4343
rustc-dep-of-std = ["nightly", "core", "compiler_builtins", "alloc", "rustc-internal-api"]
44+
raw = []
45+
46+
[package.metadata.docs.rs]
47+
features = ["nightly", "rayon", "serde", "raw"]

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ This crate has the following Cargo features:
101101
- `nightly`: Enables nightly-only features: `#[may_dangle]`.
102102
- `serde`: Enables serde serialization support.
103103
- `rayon`: Enables rayon parallel iterator support.
104+
- `raw`: Enables access to the experimental and unsafe `RawTable` API.
104105

105106
## License
106107

src/external_trait_impls/rayon/mod.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
mod helpers;
2-
mod raw;
3-
42
pub(crate) mod map;
3+
pub(crate) mod raw;
54
pub(crate) mod set;

src/lib.rs

+18-1
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,26 @@ doc_comment::doctest!("../README.md");
4343
#[macro_use]
4444
mod macros;
4545

46+
#[cfg(feature = "raw")]
47+
/// Experimental and unsafe `RawTable` API. This module is only available if the
48+
/// `raw` feature is enabled.
49+
pub mod raw {
50+
// The RawTable API is still experimental and is not properly documented yet.
51+
#[allow(missing_docs)]
52+
#[path = "mod.rs"]
53+
mod inner;
54+
pub use inner::*;
55+
56+
#[cfg(feature = "rayon")]
57+
pub mod rayon {
58+
pub use crate::external_trait_impls::rayon::raw::*;
59+
}
60+
}
61+
#[cfg(not(feature = "raw"))]
62+
mod raw;
63+
4664
mod external_trait_impls;
4765
mod map;
48-
mod raw;
4966
#[cfg(feature = "rustc-internal-api")]
5067
mod rustc_entry;
5168
mod scopeguard;

src/raw/mod.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -959,7 +959,7 @@ impl<T> RawTable<T> {
959959
/// Converts the table into a raw allocation. The contents of the table
960960
/// should be dropped using a `RawIter` before freeing the allocation.
961961
#[inline]
962-
pub fn into_alloc(self) -> Option<(NonNull<u8>, Layout)> {
962+
pub(crate) fn into_alloc(self) -> Option<(NonNull<u8>, Layout)> {
963963
let alloc = if self.is_empty_singleton() {
964964
None
965965
} else {
@@ -1080,7 +1080,7 @@ impl<T> IntoIterator for RawTable<T> {
10801080

10811081
/// Iterator over a sub-range of a table. Unlike `RawIter` this iterator does
10821082
/// not track an item count.
1083-
pub struct RawIterRange<T> {
1083+
pub(crate) struct RawIterRange<T> {
10841084
// Mask of full buckets in the current group. Bits are cleared from this
10851085
// mask as each element is processed.
10861086
current_group: BitMask,
@@ -1124,7 +1124,7 @@ impl<T> RawIterRange<T> {
11241124
/// group width.
11251125
#[inline]
11261126
#[cfg(feature = "rayon")]
1127-
pub fn split(mut self) -> (Self, Option<RawIterRange<T>>) {
1127+
pub(crate) fn split(mut self) -> (Self, Option<RawIterRange<T>>) {
11281128
unsafe {
11291129
if self.end <= self.next_ctrl {
11301130
// Nothing to split if the group that we are current processing
@@ -1219,7 +1219,7 @@ impl<T> FusedIterator for RawIterRange<T> {}
12191219

12201220
/// Iterator which returns a raw pointer to every full bucket in the table.
12211221
pub struct RawIter<T> {
1222-
pub iter: RawIterRange<T>,
1222+
pub(crate) iter: RawIterRange<T>,
12231223
items: usize,
12241224
}
12251225

0 commit comments

Comments
 (0)