Skip to content

Commit bc524d3

Browse files
committed
Auto merge of #39708 - jethrogb:patch-4, r=frewsxcv
Update set operations documentation Reminding people of set terminology.
2 parents f805144 + ba82a76 commit bc524d3

File tree

2 files changed

+30
-14
lines changed

2 files changed

+30
-14
lines changed

src/libcollections/btree/set.rs

+17-7
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,9 @@ impl<T: Ord> BTreeSet<T> {
289289
}
290290

291291
impl<T: Ord> BTreeSet<T> {
292-
/// Visits the values representing the difference, in ascending order.
292+
/// Visits the values representing the difference,
293+
/// i.e. the values that are in `self` but not in `other`,
294+
/// in ascending order.
293295
///
294296
/// # Examples
295297
///
@@ -315,7 +317,9 @@ impl<T: Ord> BTreeSet<T> {
315317
}
316318
}
317319

318-
/// Visits the values representing the symmetric difference, in ascending order.
320+
/// Visits the values representing the symmetric difference,
321+
/// i.e. the values that are in `self` or in `other` but not in both,
322+
/// in ascending order.
319323
///
320324
/// # Examples
321325
///
@@ -343,7 +347,9 @@ impl<T: Ord> BTreeSet<T> {
343347
}
344348
}
345349

346-
/// Visits the values representing the intersection, in ascending order.
350+
/// Visits the values representing the intersection,
351+
/// i.e. the values that are both in `self` and `other`,
352+
/// in ascending order.
347353
///
348354
/// # Examples
349355
///
@@ -369,7 +375,9 @@ impl<T: Ord> BTreeSet<T> {
369375
}
370376
}
371377

372-
/// Visits the values representing the union, in ascending order.
378+
/// Visits the values representing the union,
379+
/// i.e. all the values in `self` or `other`, without duplicates,
380+
/// in ascending order.
373381
///
374382
/// # Examples
375383
///
@@ -480,7 +488,7 @@ impl<T: Ord> BTreeSet<T> {
480488
Recover::get(&self.map, value)
481489
}
482490

483-
/// Returns `true` if the set has no elements in common with `other`.
491+
/// Returns `true` if `self` has no elements in common with `other`.
484492
/// This is equivalent to checking for an empty intersection.
485493
///
486494
/// # Examples
@@ -502,7 +510,8 @@ impl<T: Ord> BTreeSet<T> {
502510
self.intersection(other).next().is_none()
503511
}
504512

505-
/// Returns `true` if the set is a subset of another.
513+
/// Returns `true` if the set is a subset of another,
514+
/// i.e. `other` contains at least all the values in `self`.
506515
///
507516
/// # Examples
508517
///
@@ -544,7 +553,8 @@ impl<T: Ord> BTreeSet<T> {
544553
true
545554
}
546555

547-
/// Returns `true` if the set is a superset of another.
556+
/// Returns `true` if the set is a superset of another,
557+
/// i.e. `self` contains at least all the values in `other`.
548558
///
549559
/// # Examples
550560
///

src/libstd/collections/hash/set.rs

+13-7
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,8 @@ impl<T, S> HashSet<T, S>
291291
Iter { iter: self.map.keys() }
292292
}
293293

294-
/// Visit the values representing the difference.
294+
/// Visit the values representing the difference,
295+
/// i.e. the values that are in `self` but not in `other`.
295296
///
296297
/// # Examples
297298
///
@@ -321,7 +322,8 @@ impl<T, S> HashSet<T, S>
321322
}
322323
}
323324

324-
/// Visit the values representing the symmetric difference.
325+
/// Visit the values representing the symmetric difference,
326+
/// i.e. the values that are in `self` or in `other` but not in both.
325327
///
326328
/// # Examples
327329
///
@@ -348,7 +350,8 @@ impl<T, S> HashSet<T, S>
348350
SymmetricDifference { iter: self.difference(other).chain(other.difference(self)) }
349351
}
350352

351-
/// Visit the values representing the intersection.
353+
/// Visit the values representing the intersection,
354+
/// i.e. the values that are both in `self` and `other`.
352355
///
353356
/// # Examples
354357
///
@@ -373,7 +376,8 @@ impl<T, S> HashSet<T, S>
373376
}
374377
}
375378

376-
/// Visit the values representing the union.
379+
/// Visit the values representing the union,
380+
/// i.e. all the values in `self` or `other`, without duplicates.
377381
///
378382
/// # Examples
379383
///
@@ -489,7 +493,7 @@ impl<T, S> HashSet<T, S>
489493
Recover::get(&self.map, value)
490494
}
491495

492-
/// Returns `true` if the set has no elements in common with `other`.
496+
/// Returns `true` if `self` has no elements in common with `other`.
493497
/// This is equivalent to checking for an empty intersection.
494498
///
495499
/// # Examples
@@ -511,7 +515,8 @@ impl<T, S> HashSet<T, S>
511515
self.iter().all(|v| !other.contains(v))
512516
}
513517

514-
/// Returns `true` if the set is a subset of another.
518+
/// Returns `true` if the set is a subset of another,
519+
/// i.e. `other` contains at least all the values in `self`.
515520
///
516521
/// # Examples
517522
///
@@ -532,7 +537,8 @@ impl<T, S> HashSet<T, S>
532537
self.iter().all(|v| other.contains(v))
533538
}
534539

535-
/// Returns `true` if the set is a superset of another.
540+
/// Returns `true` if the set is a superset of another,
541+
/// i.e. `self` contains at least all the values in `other`.
536542
///
537543
/// # Examples
538544
///

0 commit comments

Comments
 (0)