Skip to content

Commit f739d6f

Browse files
committed
Experimentally expose RawTable under the "raw" feature
1 parent ed0b240 commit f739d6f

File tree

5 files changed

+23
-7
lines changed

5 files changed

+23
-7
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,4 @@ default = []
3838
nightly = []
3939
rustc-internal-api = []
4040
rustc-dep-of-std = ["nightly", "core", "compiler_builtins", "alloc", "rustc-internal-api"]
41+
raw = []

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ This crate has the following Cargo features:
8383
- `nightly`: Enables nightly-only features: `no_std` support and `#[may_dangle]`.
8484
- `serde`: Enables serde serialization support.
8585
- `rayon`: Enables rayon parallel iterator support.
86+
- `raw`: Enables access to the experimental and unsafe `RawTable` API.
8687

8788
## License
8889

src/external_trait_impls/rayon/mod.rs

Lines changed: 1 addition & 2 deletions
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

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,25 @@ doc_comment::doctest!("../README.md");
4343
#[macro_use]
4444
mod macros;
4545

46+
// The RawTable API is still experimental and is not properly documented yet.
47+
#[cfg(feature = "raw")]
48+
#[allow(missing_docs)]
49+
pub mod raw {
50+
#[path = "mod.rs"]
51+
mod inner;
52+
pub use inner::*;
53+
54+
#[cfg(feature = "rayon")]
55+
pub mod rayon {
56+
pub use crate::external_trait_impls::rayon::raw::*;
57+
}
58+
}
59+
#[cfg(not(feature = "raw"))]
60+
mod raw;
61+
4662
mod external_trait_impls;
4763
mod fx;
4864
mod map;
49-
mod raw;
5065
#[cfg(feature = "rustc-internal-api")]
5166
mod rustc_entry;
5267
mod scopeguard;

src/raw/mod.rs

Lines changed: 4 additions & 4 deletions
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)