Skip to content

Commit 34c1bfb

Browse files
committed
Remove unnecessary clones in doc examples.
1 parent 1599fad commit 34c1bfb

File tree

1 file changed

+11
-11
lines changed
  • src/libstd/collections/hash

1 file changed

+11
-11
lines changed

src/libstd/collections/hash/set.rs

+11-11
Original file line numberDiff line numberDiff line change
@@ -325,13 +325,13 @@ impl<T, S> HashSet<T, S>
325325
/// println!("{}", x); // Print 1
326326
/// }
327327
///
328-
/// let diff: HashSet<_> = a.difference(&b).cloned().collect();
329-
/// assert_eq!(diff, [1].iter().cloned().collect());
328+
/// let diff: HashSet<_> = a.difference(&b).collect();
329+
/// assert_eq!(diff, [1].iter().collect());
330330
///
331331
/// // Note that difference is not symmetric,
332332
/// // and `b - a` means something else:
333-
/// let diff: HashSet<_> = b.difference(&a).cloned().collect();
334-
/// assert_eq!(diff, [4].iter().cloned().collect());
333+
/// let diff: HashSet<_> = b.difference(&a).collect();
334+
/// assert_eq!(diff, [4].iter().collect());
335335
/// ```
336336
#[stable(feature = "rust1", since = "1.0.0")]
337337
pub fn difference<'a>(&'a self, other: &'a HashSet<T, S>) -> Difference<'a, T, S> {
@@ -356,11 +356,11 @@ impl<T, S> HashSet<T, S>
356356
/// println!("{}", x);
357357
/// }
358358
///
359-
/// let diff1: HashSet<_> = a.symmetric_difference(&b).cloned().collect();
360-
/// let diff2: HashSet<_> = b.symmetric_difference(&a).cloned().collect();
359+
/// let diff1: HashSet<_> = a.symmetric_difference(&b).collect();
360+
/// let diff2: HashSet<_> = b.symmetric_difference(&a).collect();
361361
///
362362
/// assert_eq!(diff1, diff2);
363-
/// assert_eq!(diff1, [1, 4].iter().cloned().collect());
363+
/// assert_eq!(diff1, [1, 4].iter().collect());
364364
/// ```
365365
#[stable(feature = "rust1", since = "1.0.0")]
366366
pub fn symmetric_difference<'a>(&'a self,
@@ -384,8 +384,8 @@ impl<T, S> HashSet<T, S>
384384
/// println!("{}", x);
385385
/// }
386386
///
387-
/// let intersection: HashSet<_> = a.intersection(&b).cloned().collect();
388-
/// assert_eq!(intersection, [2, 3].iter().cloned().collect());
387+
/// let intersection: HashSet<_> = a.intersection(&b).collect();
388+
/// assert_eq!(intersection, [2, 3].iter().collect());
389389
/// ```
390390
#[stable(feature = "rust1", since = "1.0.0")]
391391
pub fn intersection<'a>(&'a self, other: &'a HashSet<T, S>) -> Intersection<'a, T, S> {
@@ -410,8 +410,8 @@ impl<T, S> HashSet<T, S>
410410
/// println!("{}", x);
411411
/// }
412412
///
413-
/// let union: HashSet<_> = a.union(&b).cloned().collect();
414-
/// assert_eq!(union, [1, 2, 3, 4].iter().cloned().collect());
413+
/// let union: HashSet<_> = a.union(&b).collect();
414+
/// assert_eq!(union, [1, 2, 3, 4].iter().collect());
415415
/// ```
416416
#[stable(feature = "rust1", since = "1.0.0")]
417417
pub fn union<'a>(&'a self, other: &'a HashSet<T, S>) -> Union<'a, T, S> {

0 commit comments

Comments
 (0)