Skip to content

Commit 481ef39

Browse files
committed
Make non-assigning set ops return a set with the same type of allocator
This requires for the allocator to implement Default
1 parent 025b2ab commit 481ef39

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

src/set.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1410,9 +1410,9 @@ 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,
1413+
A: Allocator + Default,
14141414
{
1415-
type Output = HashSet<T, S>;
1415+
type Output = HashSet<T, S, A>;
14161416

14171417
/// Returns the union of `self` and `rhs` as a new `HashSet<T, S>`.
14181418
///
@@ -1434,7 +1434,7 @@ where
14341434
/// }
14351435
/// assert_eq!(i, expected.len());
14361436
/// ```
1437-
fn bitor(self, rhs: &HashSet<T, S, A>) -> HashSet<T, S> {
1437+
fn bitor(self, rhs: &HashSet<T, S, A>) -> HashSet<T, S, A> {
14381438
self.union(rhs).cloned().collect()
14391439
}
14401440
}
@@ -1443,9 +1443,9 @@ impl<T, S, A> BitAnd<&HashSet<T, S, A>> for &HashSet<T, S, A>
14431443
where
14441444
T: Eq + Hash + Clone,
14451445
S: BuildHasher + Default,
1446-
A: Allocator,
1446+
A: Allocator + Default,
14471447
{
1448-
type Output = HashSet<T, S>;
1448+
type Output = HashSet<T, S, A>;
14491449

14501450
/// Returns the intersection of `self` and `rhs` as a new `HashSet<T, S>`.
14511451
///
@@ -1467,7 +1467,7 @@ where
14671467
/// }
14681468
/// assert_eq!(i, expected.len());
14691469
/// ```
1470-
fn bitand(self, rhs: &HashSet<T, S, A>) -> HashSet<T, S> {
1470+
fn bitand(self, rhs: &HashSet<T, S, A>) -> HashSet<T, S, A> {
14711471
self.intersection(rhs).cloned().collect()
14721472
}
14731473
}
@@ -1476,9 +1476,9 @@ impl<T, S, A> BitXor<&HashSet<T, S, A>> for &HashSet<T, S, A>
14761476
where
14771477
T: Eq + Hash + Clone,
14781478
S: BuildHasher + Default,
1479-
A: Allocator,
1479+
A: Allocator + Default,
14801480
{
1481-
type Output = HashSet<T, S>;
1481+
type Output = HashSet<T, S, A>;
14821482

14831483
/// Returns the symmetric difference of `self` and `rhs` as a new `HashSet<T, S>`.
14841484
///
@@ -1500,7 +1500,7 @@ where
15001500
/// }
15011501
/// assert_eq!(i, expected.len());
15021502
/// ```
1503-
fn bitxor(self, rhs: &HashSet<T, S, A>) -> HashSet<T, S> {
1503+
fn bitxor(self, rhs: &HashSet<T, S, A>) -> HashSet<T, S, A> {
15041504
self.symmetric_difference(rhs).cloned().collect()
15051505
}
15061506
}
@@ -1509,9 +1509,9 @@ impl<T, S, A> Sub<&HashSet<T, S, A>> for &HashSet<T, S, A>
15091509
where
15101510
T: Eq + Hash + Clone,
15111511
S: BuildHasher + Default,
1512-
A: Allocator,
1512+
A: Allocator + Default,
15131513
{
1514-
type Output = HashSet<T, S>;
1514+
type Output = HashSet<T, S, A>;
15151515

15161516
/// Returns the difference of `self` and `rhs` as a new `HashSet<T, S>`.
15171517
///
@@ -1533,7 +1533,7 @@ where
15331533
/// }
15341534
/// assert_eq!(i, expected.len());
15351535
/// ```
1536-
fn sub(self, rhs: &HashSet<T, S, A>) -> HashSet<T, S> {
1536+
fn sub(self, rhs: &HashSet<T, S, A>) -> HashSet<T, S, A> {
15371537
self.difference(rhs).cloned().collect()
15381538
}
15391539
}

0 commit comments

Comments
 (0)