Move alloc::Bound to {core,std}::ops
The stable reexport `std::collections::Bound` is now deprecated. Another deprecated reexport could be added in `alloc`, but that crate is unstable.
This commit is contained in:
parent
409744bcb9
commit
c3a63970de
13 changed files with 64 additions and 63 deletions
|
@ -13,11 +13,11 @@ use core::fmt::Debug;
|
|||
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 @@ impl<K: Ord, V> BTreeMap<K, V> {
|
|||
///
|
||||
/// ```
|
||||
/// use std::collections::BTreeMap;
|
||||
/// use std::collections::Bound::Included;
|
||||
/// use std::ops::Bound::Included;
|
||||
///
|
||||
/// let mut map = BTreeMap::new();
|
||||
/// map.insert(3, "a");
|
||||
|
|
|
@ -240,7 +240,7 @@ impl<T: Ord> BTreeSet<T> {
|
|||
///
|
||||
/// ```
|
||||
/// use std::collections::BTreeSet;
|
||||
/// use std::collections::Bound::Included;
|
||||
/// use std::ops::Bound::Included;
|
||||
///
|
||||
/// let mut set = BTreeSet::new();
|
||||
/// set.insert(3);
|
||||
|
|
|
@ -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> {
|
||||
|
|
|
@ -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`.
|
||||
|
|
|
@ -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 std_unicode::char::{decode_utf16, REPLACEMENT_CHARACTER};
|
|||
|
||||
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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -75,6 +75,7 @@ use core::marker::PhantomData;
|
|||
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 boxed::Box;
|
|||
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'.
|
||||
///
|
||||
|
|
|
@ -21,6 +21,7 @@ use core::cmp::Ordering;
|
|||
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 raw_vec::RawVec;
|
|||
|
||||
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
|
||||
|
|
|
@ -192,7 +192,7 @@ pub use self::index::{Index, IndexMut};
|
|||
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;
|
||||
|
|
|
@ -442,3 +442,54 @@ impl<Idx: PartialOrd<Idx>> RangeToInclusive<Idx> {
|
|||
|
||||
// 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,
|
||||
}
|
||||
|
|
|
@ -19,8 +19,8 @@ use std::slice;
|
|||
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;
|
||||
|
|
|
@ -420,7 +420,8 @@
|
|||
#![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")]
|
||||
|
|
|
@ -18,8 +18,8 @@ use std::collections::VecDeque;
|
|||
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 {}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue