Skip to content

Commit b70c88e

Browse files
committed
Drive-by cleanup: simplify documentation of HashSet ops
1 parent e91364b commit b70c88e

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

+8-36
Original file line numberDiff line numberDiff line change
@@ -1138,15 +1138,8 @@ where
11381138
/// let a = HashSet::from([1, 2, 3]);
11391139
/// let b = HashSet::from([3, 4, 5]);
11401140
///
1141-
/// let set = &a | &b;
1142-
///
1143-
/// let mut i = 0;
1144-
/// let expected = [1, 2, 3, 4, 5];
1145-
/// for x in &set {
1146-
/// assert!(expected.contains(x));
1147-
/// i += 1;
1148-
/// }
1149-
/// assert_eq!(i, expected.len());
1141+
/// let result = &a | &b;
1142+
/// assert_eq!(result, HashSet::from([1, 2, 3, 4, 5]));
11501143
/// ```
11511144
fn bitor(self, rhs: &HashSet<T, S>) -> HashSet<T, S> {
11521145
self.union(rhs).cloned().collect()
@@ -1171,15 +1164,8 @@ where
11711164
/// let a = HashSet::from([1, 2, 3]);
11721165
/// let b = HashSet::from([2, 3, 4]);
11731166
///
1174-
/// let set = &a & &b;
1175-
///
1176-
/// let mut i = 0;
1177-
/// let expected = [2, 3];
1178-
/// for x in &set {
1179-
/// assert!(expected.contains(x));
1180-
/// i += 1;
1181-
/// }
1182-
/// assert_eq!(i, expected.len());
1167+
/// let result = &a & &b;
1168+
/// assert_eq!(result, HashSet::from([2, 3]));
11831169
/// ```
11841170
fn bitand(self, rhs: &HashSet<T, S>) -> HashSet<T, S> {
11851171
self.intersection(rhs).cloned().collect()
@@ -1204,15 +1190,8 @@ where
12041190
/// let a = HashSet::from([1, 2, 3]);
12051191
/// let b = HashSet::from([3, 4, 5]);
12061192
///
1207-
/// let set = &a ^ &b;
1208-
///
1209-
/// let mut i = 0;
1210-
/// let expected = [1, 2, 4, 5];
1211-
/// for x in &set {
1212-
/// assert!(expected.contains(x));
1213-
/// i += 1;
1214-
/// }
1215-
/// assert_eq!(i, expected.len());
1193+
/// let result = &a ^ &b;
1194+
/// assert_eq!(result, HashSet::from([1, 2, 4, 5]));
12161195
/// ```
12171196
fn bitxor(self, rhs: &HashSet<T, S>) -> HashSet<T, S> {
12181197
self.symmetric_difference(rhs).cloned().collect()
@@ -1237,15 +1216,8 @@ where
12371216
/// let a = HashSet::from([1, 2, 3]);
12381217
/// let b = HashSet::from([3, 4, 5]);
12391218
///
1240-
/// let set = &a - &b;
1241-
///
1242-
/// let mut i = 0;
1243-
/// let expected = [1, 2];
1244-
/// for x in &set {
1245-
/// assert!(expected.contains(x));
1246-
/// i += 1;
1247-
/// }
1248-
/// assert_eq!(i, expected.len());
1219+
/// let result = &a - &b;
1220+
/// assert_eq!(result, HashSet::from([1, 2]));
12491221
/// ```
12501222
fn sub(self, rhs: &HashSet<T, S>) -> HashSet<T, S> {
12511223
self.difference(rhs).cloned().collect()

0 commit comments

Comments
 (0)