Skip to content

Commit 777b15f

Browse files
committed
Drive-by cleanup: simplify documentation of HashSet ops
1 parent a73bc4a commit 777b15f

File tree

1 file changed

+8
-36
lines changed
  • library/std/src/collections/hash

1 file changed

+8
-36
lines changed

library/std/src/collections/hash/set.rs

Lines changed: 8 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1139,15 +1139,8 @@ where
11391139
/// let a = HashSet::from([1, 2, 3]);
11401140
/// let b = HashSet::from([3, 4, 5]);
11411141
///
1142-
/// let set = &a | &b;
1143-
///
1144-
/// let mut i = 0;
1145-
/// let expected = [1, 2, 3, 4, 5];
1146-
/// for x in &set {
1147-
/// assert!(expected.contains(x));
1148-
/// i += 1;
1149-
/// }
1150-
/// assert_eq!(i, expected.len());
1142+
/// let result = &a | &b;
1143+
/// assert_eq!(result, HashSet::from([1, 2, 3, 4, 5]));
11511144
/// ```
11521145
fn bitor(self, rhs: &HashSet<T, S>) -> HashSet<T, S> {
11531146
self.union(rhs).cloned().collect()
@@ -1172,15 +1165,8 @@ where
11721165
/// let a = HashSet::from([1, 2, 3]);
11731166
/// let b = HashSet::from([2, 3, 4]);
11741167
///
1175-
/// let set = &a & &b;
1176-
///
1177-
/// let mut i = 0;
1178-
/// let expected = [2, 3];
1179-
/// for x in &set {
1180-
/// assert!(expected.contains(x));
1181-
/// i += 1;
1182-
/// }
1183-
/// assert_eq!(i, expected.len());
1168+
/// let result = &a & &b;
1169+
/// assert_eq!(result, HashSet::from([2, 3]));
11841170
/// ```
11851171
fn bitand(self, rhs: &HashSet<T, S>) -> HashSet<T, S> {
11861172
self.intersection(rhs).cloned().collect()
@@ -1205,15 +1191,8 @@ where
12051191
/// let a = HashSet::from([1, 2, 3]);
12061192
/// let b = HashSet::from([3, 4, 5]);
12071193
///
1208-
/// let set = &a ^ &b;
1209-
///
1210-
/// let mut i = 0;
1211-
/// let expected = [1, 2, 4, 5];
1212-
/// for x in &set {
1213-
/// assert!(expected.contains(x));
1214-
/// i += 1;
1215-
/// }
1216-
/// assert_eq!(i, expected.len());
1194+
/// let result = &a ^ &b;
1195+
/// assert_eq!(result, HashSet::from([1, 2, 4, 5]));
12171196
/// ```
12181197
fn bitxor(self, rhs: &HashSet<T, S>) -> HashSet<T, S> {
12191198
self.symmetric_difference(rhs).cloned().collect()
@@ -1238,15 +1217,8 @@ where
12381217
/// let a = HashSet::from([1, 2, 3]);
12391218
/// let b = HashSet::from([3, 4, 5]);
12401219
///
1241-
/// let set = &a - &b;
1242-
///
1243-
/// let mut i = 0;
1244-
/// let expected = [1, 2];
1245-
/// for x in &set {
1246-
/// assert!(expected.contains(x));
1247-
/// i += 1;
1248-
/// }
1249-
/// assert_eq!(i, expected.len());
1220+
/// let result = &a - &b;
1221+
/// assert_eq!(result, HashSet::from([1, 2]));
12501222
/// ```
12511223
fn sub(self, rhs: &HashSet<T, S>) -> HashSet<T, S> {
12521224
self.difference(rhs).cloned().collect()

0 commit comments

Comments
 (0)