Skip to content

Add HashSet#raw_table #358

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 8, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions src/set.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#[cfg(feature = "raw")]
use crate::raw::RawTable;
use crate::{Equivalent, TryReserveError};
use alloc::borrow::ToOwned;
use core::fmt;
Expand Down Expand Up @@ -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 the function safe, but using raw hash table API's may require
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// Calling the function safe, but using raw hash table API's may require
/// Calling the function is safe, but using raw hash table API's may require

This should probably be fixed in the HashMap version as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed both places in 6041b5a, along with a little tweaking of the grammar in that sentence. Let me know if you'd like something different!

/// 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<T, S, A> PartialEq for HashSet<T, S, A>
Expand Down