@@ -1571,7 +1571,7 @@ where
1571
1571
impl < T , S > BitOrAssign < & HashSet < T , S > > for HashSet < T , S >
1572
1572
where
1573
1573
T : Eq + Hash + Clone ,
1574
- S : BuildHasher + Default ,
1574
+ S : BuildHasher ,
1575
1575
{
1576
1576
/// Modifies this set to contain the union of `self` and `rhs`.
1577
1577
///
@@ -1605,7 +1605,7 @@ where
1605
1605
impl < T , S > BitAndAssign < & HashSet < T , S > > for HashSet < T , S >
1606
1606
where
1607
1607
T : Eq + Hash + Clone ,
1608
- S : BuildHasher + Default ,
1608
+ S : BuildHasher ,
1609
1609
{
1610
1610
/// Modifies this set to contain the intersection of `self` and `rhs`.
1611
1611
///
@@ -1635,7 +1635,7 @@ where
1635
1635
impl < T , S > BitXorAssign < & HashSet < T , S > > for HashSet < T , S >
1636
1636
where
1637
1637
T : Eq + Hash + Clone ,
1638
- S : BuildHasher + Default ,
1638
+ S : BuildHasher ,
1639
1639
{
1640
1640
/// Modifies this set to contain the symmetric difference of `self` and `rhs`.
1641
1641
///
@@ -1671,7 +1671,7 @@ where
1671
1671
impl < T , S > AddAssign < & HashSet < T , S > > for HashSet < T , S >
1672
1672
where
1673
1673
T : Eq + Hash + Clone ,
1674
- S : BuildHasher + Default ,
1674
+ S : BuildHasher ,
1675
1675
{
1676
1676
/// Modifies this set to contain the union of `self` and `rhs`.
1677
1677
///
@@ -1705,7 +1705,7 @@ where
1705
1705
impl < T , S > SubAssign < & HashSet < T , S > > for HashSet < T , S >
1706
1706
where
1707
1707
T : Eq + Hash + Clone ,
1708
- S : BuildHasher + Default ,
1708
+ S : BuildHasher ,
1709
1709
{
1710
1710
/// Modifies this set to contain the difference of `self` and `rhs`.
1711
1711
///
@@ -1728,7 +1728,13 @@ where
1728
1728
/// assert_eq!(i, expected.len());
1729
1729
/// ```
1730
1730
fn sub_assign ( & mut self , rhs : & HashSet < T , S > ) {
1731
- self . retain ( |item| !rhs. contains ( item) ) ;
1731
+ if rhs. len ( ) < self . len ( ) {
1732
+ for item in rhs {
1733
+ self . remove ( item) ;
1734
+ }
1735
+ } else {
1736
+ self . retain ( |item| !rhs. contains ( item) ) ;
1737
+ }
1732
1738
}
1733
1739
}
1734
1740
0 commit comments