|
35 | 35 | let hash = make_hash(&self.hash_builder, &key);
|
36 | 36 | if let Some(elem) = self.table.find(hash, |q| q.0.eq(&key)) {
|
37 | 37 | RustcEntry::Occupied(RustcOccupiedEntry {
|
38 |
| - key: Some(key), |
39 | 38 | elem,
|
40 | 39 | table: &mut self.table,
|
41 | 40 | })
|
@@ -88,7 +87,6 @@ pub struct RustcOccupiedEntry<'a, K, V, A = Global>
|
88 | 87 | where
|
89 | 88 | A: Allocator,
|
90 | 89 | {
|
91 |
| - key: Option<K>, |
92 | 90 | elem: Bucket<(K, V)>,
|
93 | 91 | table: &'a mut RawTable<(K, V), A>,
|
94 | 92 | }
|
@@ -456,66 +454,6 @@ impl<'a, K, V, A: Allocator> RustcOccupiedEntry<'a, K, V, A> {
|
456 | 454 | pub fn remove(self) -> V {
|
457 | 455 | self.remove_entry().1
|
458 | 456 | }
|
459 |
| - |
460 |
| - /// Replaces the entry, returning the old key and value. The new key in the hash map will be |
461 |
| - /// the key used to create this entry. |
462 |
| - /// |
463 |
| - /// # Examples |
464 |
| - /// |
465 |
| - /// ``` |
466 |
| - /// use hashbrown::hash_map::{RustcEntry, HashMap}; |
467 |
| - /// use std::rc::Rc; |
468 |
| - /// |
469 |
| - /// let mut map: HashMap<Rc<String>, u32> = HashMap::new(); |
470 |
| - /// map.insert(Rc::new("Stringthing".to_string()), 15); |
471 |
| - /// |
472 |
| - /// let my_key = Rc::new("Stringthing".to_string()); |
473 |
| - /// |
474 |
| - /// if let RustcEntry::Occupied(entry) = map.rustc_entry(my_key) { |
475 |
| - /// // Also replace the key with a handle to our other key. |
476 |
| - /// let (old_key, old_value): (Rc<String>, u32) = entry.replace_entry(16); |
477 |
| - /// } |
478 |
| - /// |
479 |
| - /// ``` |
480 |
| - #[cfg_attr(feature = "inline-more", inline)] |
481 |
| - pub fn replace_entry(self, value: V) -> (K, V) { |
482 |
| - let entry = unsafe { self.elem.as_mut() }; |
483 |
| - |
484 |
| - let old_key = mem::replace(&mut entry.0, self.key.unwrap()); |
485 |
| - let old_value = mem::replace(&mut entry.1, value); |
486 |
| - |
487 |
| - (old_key, old_value) |
488 |
| - } |
489 |
| - |
490 |
| - /// Replaces the key in the hash map with the key used to create this entry. |
491 |
| - /// |
492 |
| - /// # Examples |
493 |
| - /// |
494 |
| - /// ``` |
495 |
| - /// use hashbrown::hash_map::{RustcEntry, HashMap}; |
496 |
| - /// use std::rc::Rc; |
497 |
| - /// |
498 |
| - /// let mut map: HashMap<Rc<String>, u32> = HashMap::new(); |
499 |
| - /// let mut known_strings: Vec<Rc<String>> = Vec::new(); |
500 |
| - /// |
501 |
| - /// // Initialise known strings, run program, etc. |
502 |
| - /// |
503 |
| - /// reclaim_memory(&mut map, &known_strings); |
504 |
| - /// |
505 |
| - /// fn reclaim_memory(map: &mut HashMap<Rc<String>, u32>, known_strings: &[Rc<String>] ) { |
506 |
| - /// for s in known_strings { |
507 |
| - /// if let RustcEntry::Occupied(entry) = map.rustc_entry(s.clone()) { |
508 |
| - /// // Replaces the entry's key with our version of it in `known_strings`. |
509 |
| - /// entry.replace_key(); |
510 |
| - /// } |
511 |
| - /// } |
512 |
| - /// } |
513 |
| - /// ``` |
514 |
| - #[cfg_attr(feature = "inline-more", inline)] |
515 |
| - pub fn replace_key(self) -> K { |
516 |
| - let entry = unsafe { self.elem.as_mut() }; |
517 |
| - mem::replace(&mut entry.0, self.key.unwrap()) |
518 |
| - } |
519 | 457 | }
|
520 | 458 |
|
521 | 459 | impl<'a, K, V, A: Allocator> RustcVacantEntry<'a, K, V, A> {
|
@@ -598,7 +536,6 @@ impl<'a, K, V, A: Allocator> RustcVacantEntry<'a, K, V, A> {
|
598 | 536 | pub fn insert_entry(self, value: V) -> RustcOccupiedEntry<'a, K, V, A> {
|
599 | 537 | let bucket = unsafe { self.table.insert_no_grow(self.hash, (self.key, value)) };
|
600 | 538 | RustcOccupiedEntry {
|
601 |
| - key: None, |
602 | 539 | elem: bucket,
|
603 | 540 | table: self.table,
|
604 | 541 | }
|
|
0 commit comments