Skip to content

Commit c3a6397

Browse files
SimonSapinManishearth
authored andcommitted
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.
1 parent 409744b commit c3a6397

File tree

13 files changed

+64
-63
lines changed

13 files changed

+64
-63
lines changed

src/liballoc/btree/map.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ use core::fmt::Debug;
1313
use core::hash::{Hash, Hasher};
1414
use core::iter::{FromIterator, Peekable, FusedIterator};
1515
use core::marker::PhantomData;
16+
use core::ops::Bound::{Excluded, Included, Unbounded};
1617
use core::ops::Index;
1718
use core::{fmt, intrinsics, mem, ptr};
1819

1920
use borrow::Borrow;
20-
use Bound::{Excluded, Included, Unbounded};
2121
use range::RangeArgument;
2222

2323
use super::node::{self, Handle, NodeRef, marker};
@@ -804,7 +804,7 @@ impl<K: Ord, V> BTreeMap<K, V> {
804804
///
805805
/// ```
806806
/// use std::collections::BTreeMap;
807-
/// use std::collections::Bound::Included;
807+
/// use std::ops::Bound::Included;
808808
///
809809
/// let mut map = BTreeMap::new();
810810
/// map.insert(3, "a");

src/liballoc/btree/set.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ impl<T: Ord> BTreeSet<T> {
240240
///
241241
/// ```
242242
/// use std::collections::BTreeSet;
243-
/// use std::collections::Bound::Included;
243+
/// use std::ops::Bound::Included;
244244
///
245245
/// let mut set = BTreeSet::new();
246246
/// set.insert(3);

src/liballoc/lib.rs

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -204,57 +204,6 @@ mod std {
204204
pub use core::ops; // RangeFull
205205
}
206206

207-
/// An endpoint of a range of keys.
208-
///
209-
/// # Examples
210-
///
211-
/// `Bound`s are range endpoints:
212-
///
213-
/// ```
214-
/// #![feature(collections_range)]
215-
///
216-
/// use std::collections::range::RangeArgument;
217-
/// use std::collections::Bound::*;
218-
///
219-
/// assert_eq!((..100).start(), Unbounded);
220-
/// assert_eq!((1..12).start(), Included(&1));
221-
/// assert_eq!((1..12).end(), Excluded(&12));
222-
/// ```
223-
///
224-
/// Using a tuple of `Bound`s as an argument to [`BTreeMap::range`].
225-
/// Note that in most cases, it's better to use range syntax (`1..5`) instead.
226-
///
227-
/// ```
228-
/// use std::collections::BTreeMap;
229-
/// use std::collections::Bound::{Excluded, Included, Unbounded};
230-
///
231-
/// let mut map = BTreeMap::new();
232-
/// map.insert(3, "a");
233-
/// map.insert(5, "b");
234-
/// map.insert(8, "c");
235-
///
236-
/// for (key, value) in map.range((Excluded(3), Included(8))) {
237-
/// println!("{}: {}", key, value);
238-
/// }
239-
///
240-
/// assert_eq!(Some((&3, &"a")), map.range((Unbounded, Included(5))).next());
241-
/// ```
242-
///
243-
/// [`BTreeMap::range`]: btree_map/struct.BTreeMap.html#method.range
244-
#[stable(feature = "collections_bound", since = "1.17.0")]
245-
#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq)]
246-
pub enum Bound<T> {
247-
/// An inclusive bound.
248-
#[stable(feature = "collections_bound", since = "1.17.0")]
249-
Included(#[stable(feature = "collections_bound", since = "1.17.0")] T),
250-
/// An exclusive bound.
251-
#[stable(feature = "collections_bound", since = "1.17.0")]
252-
Excluded(#[stable(feature = "collections_bound", since = "1.17.0")] T),
253-
/// An infinite endpoint. Indicates that there is no bound in this direction.
254-
#[stable(feature = "collections_bound", since = "1.17.0")]
255-
Unbounded,
256-
}
257-
258207
/// An intermediate trait for specialization of `Extend`.
259208
#[doc(hidden)]
260209
trait SpecExtend<I: IntoIterator> {

src/liballoc/range.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
//! Range syntax.
1616
1717
use core::ops::{RangeFull, Range, RangeTo, RangeFrom, RangeInclusive, RangeToInclusive};
18-
use Bound::{self, Excluded, Included, Unbounded};
18+
use core::ops::Bound::{self, Excluded, Included, Unbounded};
1919

2020
/// `RangeArgument` is implemented by Rust's built-in range types, produced
2121
/// by range syntax like `..`, `a..`, `..b` or `c..d`.

src/liballoc/string.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
use core::fmt;
6060
use core::hash;
6161
use core::iter::{FromIterator, FusedIterator};
62+
use core::ops::Bound::{Excluded, Included, Unbounded};
6263
use core::ops::{self, Add, AddAssign, Index, IndexMut};
6364
use core::ptr;
6465
use core::str::pattern::Pattern;
@@ -67,7 +68,6 @@ use std_unicode::char::{decode_utf16, REPLACEMENT_CHARACTER};
6768

6869
use borrow::{Cow, ToOwned};
6970
use range::RangeArgument;
70-
use Bound::{Excluded, Included, Unbounded};
7171
use str::{self, from_boxed_utf8_unchecked, FromStr, Utf8Error, Chars};
7272
use vec::Vec;
7373
use boxed::Box;

src/liballoc/tests/btree/map.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
// except according to those terms.
1010

1111
use std::collections::BTreeMap;
12-
use std::collections::Bound::{self, Excluded, Included, Unbounded};
1312
use std::collections::btree_map::Entry::{Occupied, Vacant};
13+
use std::ops::Bound::{self, Excluded, Included, Unbounded};
1414
use std::rc::Rc;
1515

1616
use std::iter::FromIterator;

src/liballoc/vec.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ use core::marker::PhantomData;
7575
use core::mem;
7676
#[cfg(not(test))]
7777
use core::num::Float;
78+
use core::ops::Bound::{Excluded, Included, Unbounded};
7879
use core::ops::{InPlace, Index, IndexMut, Place, Placer};
7980
use core::ops;
8081
use core::ptr;
@@ -87,7 +88,6 @@ use boxed::Box;
8788
use raw_vec::RawVec;
8889
use super::range::RangeArgument;
8990
use super::allocator::CollectionAllocErr;
90-
use Bound::{Excluded, Included, Unbounded};
9191

9292
/// A contiguous growable array type, written `Vec<T>` but pronounced 'vector'.
9393
///

src/liballoc/vec_deque.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ use core::cmp::Ordering;
2121
use core::fmt;
2222
use core::iter::{repeat, FromIterator, FusedIterator};
2323
use core::mem;
24+
use core::ops::Bound::{Excluded, Included, Unbounded};
2425
use core::ops::{Index, IndexMut, Place, Placer, InPlace};
2526
use core::ptr;
2627
use core::ptr::NonNull;
@@ -33,7 +34,6 @@ use raw_vec::RawVec;
3334

3435
use super::allocator::CollectionAllocErr;
3536
use super::range::RangeArgument;
36-
use Bound::{Excluded, Included, Unbounded};
3737
use super::vec::Vec;
3838

3939
const INITIAL_CAPACITY: usize = 7; // 2^3 - 1

src/libcore/ops/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ pub use self::index::{Index, IndexMut};
192192
pub use self::range::{Range, RangeFrom, RangeFull, RangeTo};
193193

194194
#[stable(feature = "inclusive_range", since = "1.26.0")]
195-
pub use self::range::{RangeInclusive, RangeToInclusive};
195+
pub use self::range::{RangeInclusive, RangeToInclusive, Bound};
196196

197197
#[unstable(feature = "try_trait", issue = "42327")]
198198
pub use self::try::Try;

src/libcore/ops/range.rs

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -442,3 +442,54 @@ impl<Idx: PartialOrd<Idx>> RangeToInclusive<Idx> {
442442

443443
// RangeToInclusive<Idx> cannot impl From<RangeTo<Idx>>
444444
// because underflow would be possible with (..0).into()
445+
446+
/// An endpoint of a range of keys.
447+
///
448+
/// # Examples
449+
///
450+
/// `Bound`s are range endpoints:
451+
///
452+
/// ```
453+
/// #![feature(collections_range)]
454+
///
455+
/// use std::collections::range::RangeArgument;
456+
/// use std::ops::Bound::*;
457+
///
458+
/// assert_eq!((..100).start(), Unbounded);
459+
/// assert_eq!((1..12).start(), Included(&1));
460+
/// assert_eq!((1..12).end(), Excluded(&12));
461+
/// ```
462+
///
463+
/// Using a tuple of `Bound`s as an argument to [`BTreeMap::range`].
464+
/// Note that in most cases, it's better to use range syntax (`1..5`) instead.
465+
///
466+
/// ```
467+
/// use std::collections::BTreeMap;
468+
/// use std::ops::Bound::{Excluded, Included, Unbounded};
469+
///
470+
/// let mut map = BTreeMap::new();
471+
/// map.insert(3, "a");
472+
/// map.insert(5, "b");
473+
/// map.insert(8, "c");
474+
///
475+
/// for (key, value) in map.range((Excluded(3), Included(8))) {
476+
/// println!("{}: {}", key, value);
477+
/// }
478+
///
479+
/// assert_eq!(Some((&3, &"a")), map.range((Unbounded, Included(5))).next());
480+
/// ```
481+
///
482+
/// [`BTreeMap::range`]: ../../std/collections/btree_map/struct.BTreeMap.html#method.range
483+
#[stable(feature = "collections_bound", since = "1.17.0")]
484+
#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq)]
485+
pub enum Bound<T> {
486+
/// An inclusive bound.
487+
#[stable(feature = "collections_bound", since = "1.17.0")]
488+
Included(#[stable(feature = "collections_bound", since = "1.17.0")] T),
489+
/// An exclusive bound.
490+
#[stable(feature = "collections_bound", since = "1.17.0")]
491+
Excluded(#[stable(feature = "collections_bound", since = "1.17.0")] T),
492+
/// An infinite endpoint. Indicates that there is no bound in this direction.
493+
#[stable(feature = "collections_bound", since = "1.17.0")]
494+
Unbounded,
495+
}

src/librustc_data_structures/array_vec.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ use std::slice;
1919
use std::fmt;
2020
use std::mem;
2121
use std::collections::range::RangeArgument;
22-
use std::collections::Bound::{Excluded, Included, Unbounded};
2322
use std::mem::ManuallyDrop;
23+
use std::ops::Bound::{Excluded, Included, Unbounded};
2424

2525
pub unsafe trait Array {
2626
type Element;

src/libstd/collections/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,8 @@
420420
#![stable(feature = "rust1", since = "1.0.0")]
421421

422422
#[stable(feature = "rust1", since = "1.0.0")]
423-
pub use alloc::Bound;
423+
#[rustc_deprecated(reason = "moved to `std::ops::Bound`", since = "1.26.0")]
424+
pub use ops::Bound;
424425
#[stable(feature = "rust1", since = "1.0.0")]
425426
pub use alloc::{BinaryHeap, BTreeMap, BTreeSet};
426427
#[stable(feature = "rust1", since = "1.0.0")]

src/test/run-pass/sync-send-iterators-in-libcollections.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ use std::collections::VecDeque;
1818
use std::collections::HashMap;
1919
use std::collections::HashSet;
2020

21-
use std::collections::Bound::Included;
2221
use std::mem;
22+
use std::ops::Bound::Included;
2323

2424
fn is_sync<T>(_: T) where T: Sync {}
2525
fn is_send<T>(_: T) where T: Send {}

0 commit comments

Comments
 (0)