summary refs log tree commit diff
path: root/src/liballoc/lib.rs
diff options
context:
space:
mode:
authorSteven Fackler <sfackler@gmail.com>2017-06-30 08:34:53 -1000
committerSteven Fackler <sfackler@gmail.com>2017-06-30 08:34:53 -1000
commit0a9c13624d2fede5c6ce8e5aa7f486403098bde6 (patch)
tree0eab912d432fe03866fdaf362710bd7bf0752703 /src/liballoc/lib.rs
parente72580cf091190c6258648e4cfbca083f20ece3d (diff)
downloadrust-0a9c13624d2fede5c6ce8e5aa7f486403098bde6.tar.gz
rust-0a9c13624d2fede5c6ce8e5aa7f486403098bde6.zip
Revert "Stabilize RangeArgument"
This reverts commit 143206d54d7558c2326212df99efc98110904fdb.
Diffstat (limited to 'src/liballoc/lib.rs')
-rw-r--r--src/liballoc/lib.rs51
1 files changed, 50 insertions, 1 deletions
diff --git a/src/liballoc/lib.rs b/src/liballoc/lib.rs
index 6f4e300fd3c..ca52943ea97 100644
--- a/src/liballoc/lib.rs
+++ b/src/liballoc/lib.rs
@@ -203,7 +203,56 @@ mod std {
     pub use core::ops;      // RangeFull
 }
 
-pub use core::ops::Bound;
+/// An endpoint of a range of keys.
+///
+/// # Examples
+///
+/// `Bound`s are range endpoints:
+///
+/// ```
+/// #![feature(collections_range)]
+///
+/// use std::collections::range::RangeArgument;
+/// use std::collections::Bound::*;
+///
+/// assert_eq!((..100).start(), Unbounded);
+/// assert_eq!((1..12).start(), Included(&1));
+/// assert_eq!((1..12).end(), Excluded(&12));
+/// ```
+///
+/// Using a tuple of `Bound`s as an argument to [`BTreeMap::range`].
+/// Note that in most cases, it's better to use range syntax (`1..5`) instead.
+///
+/// ```
+/// use std::collections::BTreeMap;
+/// use std::collections::Bound::{Excluded, Included, Unbounded};
+///
+/// let mut map = BTreeMap::new();
+/// map.insert(3, "a");
+/// map.insert(5, "b");
+/// map.insert(8, "c");
+///
+/// for (key, value) in map.range((Excluded(3), Included(8))) {
+///     println!("{}: {}", key, value);
+/// }
+///
+/// assert_eq!(Some((&3, &"a")), map.range((Unbounded, Included(5))).next());
+/// ```
+///
+/// [`BTreeMap::range`]: btree_map/struct.BTreeMap.html#method.range
+#[stable(feature = "collections_bound", since = "1.17.0")]
+#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq)]
+pub enum Bound<T> {
+    /// An inclusive bound.
+    #[stable(feature = "collections_bound", since = "1.17.0")]
+    Included(T),
+    /// An exclusive bound.
+    #[stable(feature = "collections_bound", since = "1.17.0")]
+    Excluded(T),
+    /// An infinite endpoint. Indicates that there is no bound in this direction.
+    #[stable(feature = "collections_bound", since = "1.17.0")]
+    Unbounded,
+}
 
 /// An intermediate trait for specialization of `Extend`.
 #[doc(hidden)]