@@ -4,7 +4,6 @@ use crate::hash::{Hash, BuildHasher};
44use crate :: iter:: { Chain , FromIterator , FusedIterator } ;
55use crate :: ops:: { BitOr , BitAnd , BitXor , Sub } ;
66
7- use super :: Recover ;
87use super :: map:: { self , HashMap , Keys , RandomState } ;
98
109// Future Optimization (FIXME!)
@@ -579,7 +578,7 @@ impl<T, S> HashSet<T, S>
579578 where T : Borrow < Q > ,
580579 Q : Hash + Eq
581580 {
582- Recover :: get ( & self . map , value )
581+ self . map . get_key_value ( value ) . map ( | ( k , _ ) | k )
583582 }
584583
585584 /// Returns `true` if `self` has no elements in common with `other`.
@@ -699,7 +698,13 @@ impl<T, S> HashSet<T, S>
699698 /// ```
700699 #[ stable( feature = "set_recovery" , since = "1.9.0" ) ]
701700 pub fn replace ( & mut self , value : T ) -> Option < T > {
702- Recover :: replace ( & mut self . map , value)
701+ match self . map . entry ( value) {
702+ map:: Entry :: Occupied ( occupied) => Some ( occupied. replace_key ( ) ) ,
703+ map:: Entry :: Vacant ( vacant) => {
704+ vacant. insert ( ( ) ) ;
705+ None
706+ }
707+ }
703708 }
704709
705710 /// Removes a value from the set. Returns whether the value was
@@ -754,7 +759,7 @@ impl<T, S> HashSet<T, S>
754759 where T : Borrow < Q > ,
755760 Q : Hash + Eq
756761 {
757- Recover :: take ( & mut self . map , value )
762+ self . map . remove_entry ( value ) . map ( | ( k , _ ) | k )
758763 }
759764
760765 /// Retains only the elements specified by the predicate.
0 commit comments