Skip to content

Commit e54c160

Browse files
committed
Auto merge of #342 - cuviper:set-entry, r=Amanieu
Add an Entry API for HashSet This adds `HashSet::entry` and `rustc_entry`, mimicking the API of `HashMap`. The "rustc" variants are without the `S` type parameter, just like the difference on maps. Set entries have fewer methods since there's no mutable value like in maps, but the basic insert/remove/replace functionality is there. Resolves #274.
2 parents 0f5798f + af67f7d commit e54c160

File tree

3 files changed

+445
-4
lines changed

3 files changed

+445
-4
lines changed

src/map.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5573,7 +5573,7 @@ impl<'a, K, V, S, A: Allocator + Clone> VacantEntry<'a, K, V, S, A> {
55735573
}
55745574

55755575
#[cfg_attr(feature = "inline-more", inline)]
5576-
fn insert_entry(self, value: V) -> OccupiedEntry<'a, K, V, S, A>
5576+
pub(crate) fn insert_entry(self, value: V) -> OccupiedEntry<'a, K, V, S, A>
55775577
where
55785578
K: Hash,
55795579
S: BuildHasher,

src/rustc_entry.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,10 @@ where
5656

5757
/// A view into a single entry in a map, which may either be vacant or occupied.
5858
///
59-
/// This `enum` is constructed from the [`entry`] method on [`HashMap`].
59+
/// This `enum` is constructed from the [`rustc_entry`] method on [`HashMap`].
6060
///
6161
/// [`HashMap`]: struct.HashMap.html
62-
/// [`entry`]: struct.HashMap.html#method.rustc_entry
62+
/// [`rustc_entry`]: struct.HashMap.html#method.rustc_entry
6363
pub enum RustcEntry<'a, K, V, A = Global>
6464
where
6565
A: Allocator + Clone,
@@ -145,7 +145,7 @@ impl<'a, K, V, A: Allocator + Clone> RustcEntry<'a, K, V, A> {
145145
/// use hashbrown::HashMap;
146146
///
147147
/// let mut map: HashMap<&str, u32> = HashMap::new();
148-
/// let entry = map.entry("horseyland").insert(37);
148+
/// let entry = map.rustc_entry("horseyland").insert(37);
149149
///
150150
/// assert_eq!(entry.key(), &"horseyland");
151151
/// ```

0 commit comments

Comments
 (0)