diff --git a/src/map.rs b/src/map.rs index 6a1e18c23b..9696de665d 100644 --- a/src/map.rs +++ b/src/map.rs @@ -1996,7 +1996,7 @@ impl HashMap { /// /// # Note /// - /// Calling the function safe, but using raw hash table API's may require + /// Calling this function is safe, but using the raw hash table API may require /// unsafe functions or blocks. /// /// `RawTable` API gives the lowest level of control under the map that can be useful diff --git a/src/set.rs b/src/set.rs index c3e14affe1..f91cb54fcb 100644 --- a/src/set.rs +++ b/src/set.rs @@ -1,3 +1,5 @@ +#[cfg(feature = "raw")] +use crate::raw::RawTable; use crate::{Equivalent, TryReserveError}; use alloc::borrow::ToOwned; use core::fmt; @@ -1135,6 +1137,26 @@ where None => None, } } + + /// Returns a mutable reference to the [`RawTable`] used underneath [`HashSet`]. + /// This function is only available if the `raw` feature of the crate is enabled. + /// + /// # Note + /// + /// Calling this function is safe, but using the raw hash table API may require + /// unsafe functions or blocks. + /// + /// `RawTable` API gives the lowest level of control under the set that can be useful + /// for extending the HashSet's API, but may lead to *[undefined behavior]*. + /// + /// [`HashSet`]: struct.HashSet.html + /// [`RawTable`]: raw/struct.RawTable.html + /// [undefined behavior]: https://doc.rust-lang.org/reference/behavior-considered-undefined.html + #[cfg(feature = "raw")] + #[cfg_attr(feature = "inline-more", inline)] + pub fn raw_table(&mut self) -> &mut RawTable<(T, ()), A> { + self.map.raw_table() + } } impl PartialEq for HashSet