]> git.lizzy.rs Git - rust.git/commitdiff
Move alloc::Bound to {core,std}::ops
authorSimon Sapin <simon.sapin@exyr.org>
Mon, 19 Mar 2018 08:01:17 +0000 (09:01 +0100)
committerManish Goregaokar <manishsmail@gmail.com>
Thu, 29 Mar 2018 11:12:49 +0000 (13:12 +0200)
The stable reexport `std::collections::Bound` is now deprecated.

Another deprecated reexport could be added in `alloc`,
but that crate is unstable.

13 files changed:
src/liballoc/btree/map.rs
src/liballoc/btree/set.rs
src/liballoc/lib.rs
src/liballoc/range.rs
src/liballoc/string.rs
src/liballoc/tests/btree/map.rs
src/liballoc/vec.rs
src/liballoc/vec_deque.rs
src/libcore/ops/mod.rs
src/libcore/ops/range.rs
src/librustc_data_structures/array_vec.rs
src/libstd/collections/mod.rs
src/test/run-pass/sync-send-iterators-in-libcollections.rs

index cada190032aa064c806545b65c9c96ec05e3b65b..2ba56063e36601e9e5a01cd89ed215dea10cab91 100644 (file)
 use core::hash::{Hash, Hasher};
 use core::iter::{FromIterator, Peekable, FusedIterator};
 use core::marker::PhantomData;
+use core::ops::Bound::{Excluded, Included, Unbounded};
 use core::ops::Index;
 use core::{fmt, intrinsics, mem, ptr};
 
 use borrow::Borrow;
-use Bound::{Excluded, Included, Unbounded};
 use range::RangeArgument;
 
 use super::node::{self, Handle, NodeRef, marker};
@@ -804,7 +804,7 @@ pub fn append(&mut self, other: &mut Self) {
     ///
     /// ```
     /// use std::collections::BTreeMap;
-    /// use std::collections::Bound::Included;
+    /// use std::ops::Bound::Included;
     ///
     /// let mut map = BTreeMap::new();
     /// map.insert(3, "a");
index 2e3157147a085b9a8086c4ad48fd83584a87662c..d488dd6cbbd7337bb2ebd5289a1a8f26694d112d 100644 (file)
@@ -240,7 +240,7 @@ pub fn new() -> BTreeSet<T> {
     ///
     /// ```
     /// use std::collections::BTreeSet;
-    /// use std::collections::Bound::Included;
+    /// use std::ops::Bound::Included;
     ///
     /// let mut set = BTreeSet::new();
     /// set.insert(3);
index 19d64d8fea9ecbed5765eaa59b85cfd578c12fed..eddbd50ea0381204613137ae3d1585a3c8492fb2 100644 (file)
@@ -204,57 +204,6 @@ mod std {
     pub use core::ops;      // RangeFull
 }
 
-/// 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(#[stable(feature = "collections_bound", since = "1.17.0")] T),
-    /// An exclusive bound.
-    #[stable(feature = "collections_bound", since = "1.17.0")]
-    Excluded(#[stable(feature = "collections_bound", since = "1.17.0")] 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)]
 trait SpecExtend<I: IntoIterator> {
index b03abc8518087addd1b7d8976c3a0a1f45e06ca8..7cadbf3c90a024070280c6c4afc751f5fed1ad5b 100644 (file)
@@ -15,7 +15,7 @@
 //! Range syntax.
 
 use core::ops::{RangeFull, Range, RangeTo, RangeFrom, RangeInclusive, RangeToInclusive};
-use Bound::{self, Excluded, Included, Unbounded};
+use core::ops::Bound::{self, Excluded, Included, Unbounded};
 
 /// `RangeArgument` is implemented by Rust's built-in range types, produced
 /// by range syntax like `..`, `a..`, `..b` or `c..d`.
index 23c12bef3aa7cc2166a21bde49d97920f71c7180..754c78f777990522145c98f6d7a560ad3e8c3274 100644 (file)
@@ -59,6 +59,7 @@
 use core::fmt;
 use core::hash;
 use core::iter::{FromIterator, FusedIterator};
+use core::ops::Bound::{Excluded, Included, Unbounded};
 use core::ops::{self, Add, AddAssign, Index, IndexMut};
 use core::ptr;
 use core::str::pattern::Pattern;
@@ -67,7 +68,6 @@
 
 use borrow::{Cow, ToOwned};
 use range::RangeArgument;
-use Bound::{Excluded, Included, Unbounded};
 use str::{self, from_boxed_utf8_unchecked, FromStr, Utf8Error, Chars};
 use vec::Vec;
 use boxed::Box;
index 2393101040d9f9d3781df9a0f396026775be4d23..6ebdb86cc4a9865a42bdde87419e87503ef249f0 100644 (file)
@@ -9,8 +9,8 @@
 // except according to those terms.
 
 use std::collections::BTreeMap;
-use std::collections::Bound::{self, Excluded, Included, Unbounded};
 use std::collections::btree_map::Entry::{Occupied, Vacant};
+use std::ops::Bound::{self, Excluded, Included, Unbounded};
 use std::rc::Rc;
 
 use std::iter::FromIterator;
index bcc999d73863318b6c87ec0e25052ca452143229..280570ecd65cbb1a232745758a6812096c349910 100644 (file)
@@ -75,6 +75,7 @@
 use core::mem;
 #[cfg(not(test))]
 use core::num::Float;
+use core::ops::Bound::{Excluded, Included, Unbounded};
 use core::ops::{InPlace, Index, IndexMut, Place, Placer};
 use core::ops;
 use core::ptr;
@@ -87,7 +88,6 @@
 use raw_vec::RawVec;
 use super::range::RangeArgument;
 use super::allocator::CollectionAllocErr;
-use Bound::{Excluded, Included, Unbounded};
 
 /// A contiguous growable array type, written `Vec<T>` but pronounced 'vector'.
 ///
index be6e8d0f22f07bea2c6e5e299e478311d2209852..9efd730790d3bdf827d7f29a02264c31309b7270 100644 (file)
@@ -21,6 +21,7 @@
 use core::fmt;
 use core::iter::{repeat, FromIterator, FusedIterator};
 use core::mem;
+use core::ops::Bound::{Excluded, Included, Unbounded};
 use core::ops::{Index, IndexMut, Place, Placer, InPlace};
 use core::ptr;
 use core::ptr::NonNull;
@@ -33,7 +34,6 @@
 
 use super::allocator::CollectionAllocErr;
 use super::range::RangeArgument;
-use Bound::{Excluded, Included, Unbounded};
 use super::vec::Vec;
 
 const INITIAL_CAPACITY: usize = 7; // 2^3 - 1
index 234970a81faf72c36d3dc3511a6b74c3ec3f7eab..b0e75135282631c03d32a017d1e62af62c123ace 100644 (file)
 pub use self::range::{Range, RangeFrom, RangeFull, RangeTo};
 
 #[stable(feature = "inclusive_range", since = "1.26.0")]
-pub use self::range::{RangeInclusive, RangeToInclusive};
+pub use self::range::{RangeInclusive, RangeToInclusive, Bound};
 
 #[unstable(feature = "try_trait", issue = "42327")]
 pub use self::try::Try;
index be51f5239b0c64c2aef58bdce6611b8be78e19f6..dd44aedd09f5aeb9b6a68ee9b56c325e1305ac63 100644 (file)
@@ -442,3 +442,54 @@ pub fn contains(&self, item: Idx) -> bool {
 
 // RangeToInclusive<Idx> cannot impl From<RangeTo<Idx>>
 // because underflow would be possible with (..0).into()
+
+/// An endpoint of a range of keys.
+///
+/// # Examples
+///
+/// `Bound`s are range endpoints:
+///
+/// ```
+/// #![feature(collections_range)]
+///
+/// use std::collections::range::RangeArgument;
+/// use std::ops::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::ops::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`]: ../../std/collections/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(#[stable(feature = "collections_bound", since = "1.17.0")] T),
+    /// An exclusive bound.
+    #[stable(feature = "collections_bound", since = "1.17.0")]
+    Excluded(#[stable(feature = "collections_bound", since = "1.17.0")] T),
+    /// An infinite endpoint. Indicates that there is no bound in this direction.
+    #[stable(feature = "collections_bound", since = "1.17.0")]
+    Unbounded,
+}
index 511c407d45a7fef0ad7d7cb0f5d937041b93826e..b40f2f922379bc868da5647fa1924c2892018392 100644 (file)
@@ -19,8 +19,8 @@
 use std::fmt;
 use std::mem;
 use std::collections::range::RangeArgument;
-use std::collections::Bound::{Excluded, Included, Unbounded};
 use std::mem::ManuallyDrop;
+use std::ops::Bound::{Excluded, Included, Unbounded};
 
 pub unsafe trait Array {
     type Element;
index be88f4e268aa0b0ffb6ecd1a43e59af60989d36f..e6f15a6119e075e1c04f2d9ba172a9887a21f346 100644 (file)
 #![stable(feature = "rust1", since = "1.0.0")]
 
 #[stable(feature = "rust1", since = "1.0.0")]
-pub use alloc::Bound;
+#[rustc_deprecated(reason = "moved to `std::ops::Bound`", since = "1.26.0")]
+pub use ops::Bound;
 #[stable(feature = "rust1", since = "1.0.0")]
 pub use alloc::{BinaryHeap, BTreeMap, BTreeSet};
 #[stable(feature = "rust1", since = "1.0.0")]
index 903532e9bc80ac325af1e4f4b34b07783da83468..e096fb3bbaef723a60aea7d1d43b5656cbe14de4 100644 (file)
@@ -18,8 +18,8 @@
 use std::collections::HashMap;
 use std::collections::HashSet;
 
-use std::collections::Bound::Included;
 use std::mem;
+use std::ops::Bound::Included;
 
 fn is_sync<T>(_: T) where T: Sync {}
 fn is_send<T>(_: T) where T: Send {}