]> git.proxmox.com Git - rustc.git/blobdiff - src/libcollections/btree/set.rs
New upstream version 1.17.0+dfsg1
[rustc.git] / src / libcollections / btree / set.rs
index f006ba95371611ecb402bbde92048c36217e4f77..72d25f87bca9515858b9765f7dc047d90841ddc1 100644 (file)
@@ -85,6 +85,15 @@ pub struct Iter<'a, T: 'a> {
     iter: Keys<'a, T, ()>,
 }
 
+#[stable(feature = "collection_debug", since = "1.17.0")]
+impl<'a, T: 'a + fmt::Debug> fmt::Debug for Iter<'a, T> {
+    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+        f.debug_tuple("Iter")
+         .field(&self.iter.clone())
+         .finish()
+    }
+}
+
 /// An owning iterator over a `BTreeSet`'s items.
 ///
 /// This structure is created by the `into_iter` method on [`BTreeSet`]
@@ -92,6 +101,7 @@ pub struct Iter<'a, T: 'a> {
 ///
 /// [`BTreeSet`]: struct.BTreeSet.html
 #[stable(feature = "rust1", since = "1.0.0")]
+#[derive(Debug)]
 pub struct IntoIter<T> {
     iter: ::btree_map::IntoIter<T, ()>,
 }
@@ -102,6 +112,8 @@ pub struct IntoIter<T> {
 ///
 /// [`BTreeSet`]: struct.BTreeSet.html
 /// [`range`]: struct.BTreeSet.html#method.range
+#[derive(Debug)]
+#[stable(feature = "btree_range", since = "1.17.0")]
 pub struct Range<'a, T: 'a> {
     iter: ::btree_map::Range<'a, T, ()>,
 }
@@ -118,6 +130,15 @@ pub struct Difference<'a, T: 'a> {
     b: Peekable<Iter<'a, T>>,
 }
 
+#[stable(feature = "collection_debug", since = "1.17.0")]
+impl<'a, T: 'a + fmt::Debug> fmt::Debug for Difference<'a, T> {
+    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+        f.debug_tuple("Difference")
+         .field(&self.clone())
+         .finish()
+    }
+}
+
 /// A lazy iterator producing elements in the set symmetric difference (in-order).
 ///
 /// This structure is created by the [`symmetric_difference`] method on
@@ -131,6 +152,15 @@ pub struct SymmetricDifference<'a, T: 'a> {
     b: Peekable<Iter<'a, T>>,
 }
 
+#[stable(feature = "collection_debug", since = "1.17.0")]
+impl<'a, T: 'a + fmt::Debug> fmt::Debug for SymmetricDifference<'a, T> {
+    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+        f.debug_tuple("SymmetricDifference")
+         .field(&self.clone())
+         .finish()
+    }
+}
+
 /// A lazy iterator producing elements in the set intersection (in-order).
 ///
 /// This structure is created by the [`intersection`] method on [`BTreeSet`].
@@ -143,6 +173,15 @@ pub struct Intersection<'a, T: 'a> {
     b: Peekable<Iter<'a, T>>,
 }
 
+#[stable(feature = "collection_debug", since = "1.17.0")]
+impl<'a, T: 'a + fmt::Debug> fmt::Debug for Intersection<'a, T> {
+    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+        f.debug_tuple("Intersection")
+         .field(&self.clone())
+         .finish()
+    }
+}
+
 /// A lazy iterator producing elements in the set union (in-order).
 ///
 /// This structure is created by the [`union`] method on [`BTreeSet`].
@@ -155,6 +194,15 @@ pub struct Union<'a, T: 'a> {
     b: Peekable<Iter<'a, T>>,
 }
 
+#[stable(feature = "collection_debug", since = "1.17.0")]
+impl<'a, T: 'a + fmt::Debug> fmt::Debug for Union<'a, T> {
+    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+        f.debug_tuple("Union")
+         .field(&self.clone())
+         .finish()
+    }
+}
+
 impl<T: Ord> BTreeSet<T> {
     /// Makes a new `BTreeSet` with a reasonable choice of B.
     ///
@@ -217,8 +265,6 @@ impl<T: Ord> BTreeSet<T> {
     /// # Examples
     ///
     /// ```
-    /// #![feature(btree_range, collections_bound)]
-    ///
     /// use std::collections::BTreeSet;
     /// use std::collections::Bound::Included;
     ///
@@ -231,9 +277,7 @@ impl<T: Ord> BTreeSet<T> {
     /// }
     /// assert_eq!(Some(&5), set.range(4..).next());
     /// ```
-    #[unstable(feature = "btree_range",
-               reason = "matches collection reform specification, waiting for dust to settle",
-               issue = "27787")]
+    #[stable(feature = "btree_range", since = "1.17.0")]
     pub fn range<K: ?Sized, R>(&self, range: R) -> Range<T>
         where K: Ord, T: Borrow<K>, R: RangeArgument<K>
     {
@@ -242,7 +286,9 @@ impl<T: Ord> BTreeSet<T> {
 }
 
 impl<T: Ord> BTreeSet<T> {
-    /// Visits the values representing the difference, in ascending order.
+    /// Visits the values representing the difference,
+    /// i.e. the values that are in `self` but not in `other`,
+    /// in ascending order.
     ///
     /// # Examples
     ///
@@ -268,7 +314,9 @@ impl<T: Ord> BTreeSet<T> {
         }
     }
 
-    /// Visits the values representing the symmetric difference, in ascending order.
+    /// Visits the values representing the symmetric difference,
+    /// i.e. the values that are in `self` or in `other` but not in both,
+    /// in ascending order.
     ///
     /// # Examples
     ///
@@ -296,7 +344,9 @@ impl<T: Ord> BTreeSet<T> {
         }
     }
 
-    /// Visits the values representing the intersection, in ascending order.
+    /// Visits the values representing the intersection,
+    /// i.e. the values that are both in `self` and `other`,
+    /// in ascending order.
     ///
     /// # Examples
     ///
@@ -322,7 +372,9 @@ impl<T: Ord> BTreeSet<T> {
         }
     }
 
-    /// Visits the values representing the union, in ascending order.
+    /// Visits the values representing the union,
+    /// i.e. all the values in `self` or `other`, without duplicates,
+    /// in ascending order.
     ///
     /// # Examples
     ///
@@ -433,7 +485,7 @@ impl<T: Ord> BTreeSet<T> {
         Recover::get(&self.map, value)
     }
 
-    /// Returns `true` if the set has no elements in common with `other`.
+    /// Returns `true` if `self` has no elements in common with `other`.
     /// This is equivalent to checking for an empty intersection.
     ///
     /// # Examples
@@ -455,7 +507,8 @@ impl<T: Ord> BTreeSet<T> {
         self.intersection(other).next().is_none()
     }
 
-    /// Returns `true` if the set is a subset of another.
+    /// Returns `true` if the set is a subset of another,
+    /// i.e. `other` contains at least all the values in `self`.
     ///
     /// # Examples
     ///
@@ -497,7 +550,8 @@ impl<T: Ord> BTreeSet<T> {
         true
     }
 
-    /// Returns `true` if the set is a superset of another.
+    /// Returns `true` if the set is a superset of another,
+    /// i.e. `self` contains at least all the values in `other`.
     ///
     /// # Examples
     ///