Skip to content

Commit 025b2ab

Browse files
committed
Add A: Allocator bound to set operations
1 parent 2d289cc commit 025b2ab

File tree

1 file changed

+24
-16
lines changed

1 file changed

+24
-16
lines changed

src/set.rs

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1406,10 +1406,11 @@ where
14061406
}
14071407
}
14081408

1409-
impl<T, S> BitOr<&HashSet<T, S>> for &HashSet<T, S>
1409+
impl<T, S, A> BitOr<&HashSet<T, S, A>> for &HashSet<T, S, A>
14101410
where
14111411
T: Eq + Hash + Clone,
14121412
S: BuildHasher + Default,
1413+
A: Allocator,
14131414
{
14141415
type Output = HashSet<T, S>;
14151416

@@ -1433,15 +1434,16 @@ where
14331434
/// }
14341435
/// assert_eq!(i, expected.len());
14351436
/// ```
1436-
fn bitor(self, rhs: &HashSet<T, S>) -> HashSet<T, S> {
1437+
fn bitor(self, rhs: &HashSet<T, S, A>) -> HashSet<T, S> {
14371438
self.union(rhs).cloned().collect()
14381439
}
14391440
}
14401441

1441-
impl<T, S> BitAnd<&HashSet<T, S>> for &HashSet<T, S>
1442+
impl<T, S, A> BitAnd<&HashSet<T, S, A>> for &HashSet<T, S, A>
14421443
where
14431444
T: Eq + Hash + Clone,
14441445
S: BuildHasher + Default,
1446+
A: Allocator,
14451447
{
14461448
type Output = HashSet<T, S>;
14471449

@@ -1465,15 +1467,16 @@ where
14651467
/// }
14661468
/// assert_eq!(i, expected.len());
14671469
/// ```
1468-
fn bitand(self, rhs: &HashSet<T, S>) -> HashSet<T, S> {
1470+
fn bitand(self, rhs: &HashSet<T, S, A>) -> HashSet<T, S> {
14691471
self.intersection(rhs).cloned().collect()
14701472
}
14711473
}
14721474

1473-
impl<T, S> BitXor<&HashSet<T, S>> for &HashSet<T, S>
1475+
impl<T, S, A> BitXor<&HashSet<T, S, A>> for &HashSet<T, S, A>
14741476
where
14751477
T: Eq + Hash + Clone,
14761478
S: BuildHasher + Default,
1479+
A: Allocator,
14771480
{
14781481
type Output = HashSet<T, S>;
14791482

@@ -1497,15 +1500,16 @@ where
14971500
/// }
14981501
/// assert_eq!(i, expected.len());
14991502
/// ```
1500-
fn bitxor(self, rhs: &HashSet<T, S>) -> HashSet<T, S> {
1503+
fn bitxor(self, rhs: &HashSet<T, S, A>) -> HashSet<T, S> {
15011504
self.symmetric_difference(rhs).cloned().collect()
15021505
}
15031506
}
15041507

1505-
impl<T, S> Sub<&HashSet<T, S>> for &HashSet<T, S>
1508+
impl<T, S, A> Sub<&HashSet<T, S, A>> for &HashSet<T, S, A>
15061509
where
15071510
T: Eq + Hash + Clone,
15081511
S: BuildHasher + Default,
1512+
A: Allocator,
15091513
{
15101514
type Output = HashSet<T, S>;
15111515

@@ -1529,15 +1533,16 @@ where
15291533
/// }
15301534
/// assert_eq!(i, expected.len());
15311535
/// ```
1532-
fn sub(self, rhs: &HashSet<T, S>) -> HashSet<T, S> {
1536+
fn sub(self, rhs: &HashSet<T, S, A>) -> HashSet<T, S> {
15331537
self.difference(rhs).cloned().collect()
15341538
}
15351539
}
15361540

1537-
impl<T, S> BitOrAssign<&HashSet<T, S>> for HashSet<T, S>
1541+
impl<T, S, A> BitOrAssign<&HashSet<T, S, A>> for HashSet<T, S, A>
15381542
where
15391543
T: Eq + Hash + Clone,
15401544
S: BuildHasher,
1545+
A: Allocator,
15411546
{
15421547
/// Modifies this set to contain the union of `self` and `rhs`.
15431548
///
@@ -1559,7 +1564,7 @@ where
15591564
/// }
15601565
/// assert_eq!(i, expected.len());
15611566
/// ```
1562-
fn bitor_assign(&mut self, rhs: &HashSet<T, S>) {
1567+
fn bitor_assign(&mut self, rhs: &HashSet<T, S, A>) {
15631568
for item in rhs {
15641569
if !self.contains(item) {
15651570
self.insert(item.clone());
@@ -1568,10 +1573,11 @@ where
15681573
}
15691574
}
15701575

1571-
impl<T, S> BitAndAssign<&HashSet<T, S>> for HashSet<T, S>
1576+
impl<T, S, A> BitAndAssign<&HashSet<T, S, A>> for HashSet<T, S, A>
15721577
where
15731578
T: Eq + Hash + Clone,
15741579
S: BuildHasher,
1580+
A: Allocator,
15751581
{
15761582
/// Modifies this set to contain the intersection of `self` and `rhs`.
15771583
///
@@ -1593,15 +1599,16 @@ where
15931599
/// }
15941600
/// assert_eq!(i, expected.len());
15951601
/// ```
1596-
fn bitand_assign(&mut self, rhs: &HashSet<T, S>) {
1602+
fn bitand_assign(&mut self, rhs: &HashSet<T, S, A>) {
15971603
self.retain(|item| rhs.contains(item));
15981604
}
15991605
}
16001606

1601-
impl<T, S> BitXorAssign<&HashSet<T, S>> for HashSet<T, S>
1607+
impl<T, S, A> BitXorAssign<&HashSet<T, S, A>> for HashSet<T, S, A>
16021608
where
16031609
T: Eq + Hash + Clone,
16041610
S: BuildHasher,
1611+
A: Allocator,
16051612
{
16061613
/// Modifies this set to contain the symmetric difference of `self` and `rhs`.
16071614
///
@@ -1623,7 +1630,7 @@ where
16231630
/// }
16241631
/// assert_eq!(i, expected.len());
16251632
/// ```
1626-
fn bitxor_assign(&mut self, rhs: &HashSet<T, S>) {
1633+
fn bitxor_assign(&mut self, rhs: &HashSet<T, S, A>) {
16271634
for item in rhs {
16281635
let entry = self.map.raw_entry_mut().from_key(item);
16291636
match entry {
@@ -1638,10 +1645,11 @@ where
16381645
}
16391646
}
16401647

1641-
impl<T, S> SubAssign<&HashSet<T, S>> for HashSet<T, S>
1648+
impl<T, S, A> SubAssign<&HashSet<T, S, A>> for HashSet<T, S, A>
16421649
where
16431650
T: Eq + Hash + Clone,
16441651
S: BuildHasher,
1652+
A: Allocator,
16451653
{
16461654
/// Modifies this set to contain the difference of `self` and `rhs`.
16471655
///
@@ -1663,7 +1671,7 @@ where
16631671
/// }
16641672
/// assert_eq!(i, expected.len());
16651673
/// ```
1666-
fn sub_assign(&mut self, rhs: &HashSet<T, S>) {
1674+
fn sub_assign(&mut self, rhs: &HashSet<T, S, A>) {
16671675
if rhs.len() < self.len() {
16681676
for item in rhs {
16691677
self.remove(item);

0 commit comments

Comments
 (0)