Skip to content

Commit 9e08920

Browse files
author
Clar Charr
committed
Move Bound to libcore.
1 parent a11c26f commit 9e08920

File tree

3 files changed

+60
-50
lines changed

3 files changed

+60
-50
lines changed

src/libcollections/lib.rs

Lines changed: 2 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -129,59 +129,11 @@ pub mod btree_set {
129129

130130
#[cfg(not(test))]
131131
mod std {
132-
pub use core::ops; // RangeFull
132+
pub use core::ops; // RangeFull
133133
}
134134

135-
/// An endpoint of a range of keys.
136-
///
137-
/// # Examples
138-
///
139-
/// `Bound`s are range endpoints:
140-
///
141-
/// ```
142-
/// #![feature(collections_range)]
143-
///
144-
/// use std::collections::range::RangeArgument;
145-
/// use std::collections::Bound::*;
146-
///
147-
/// assert_eq!((..100).start(), Unbounded);
148-
/// assert_eq!((1..12).start(), Included(&1));
149-
/// assert_eq!((1..12).end(), Excluded(&12));
150-
/// ```
151-
///
152-
/// Using a tuple of `Bound`s as an argument to [`BTreeMap::range`].
153-
/// Note that in most cases, it's better to use range syntax (`1..5`) instead.
154-
///
155-
/// ```
156-
/// use std::collections::BTreeMap;
157-
/// use std::collections::Bound::{Excluded, Included, Unbounded};
158-
///
159-
/// let mut map = BTreeMap::new();
160-
/// map.insert(3, "a");
161-
/// map.insert(5, "b");
162-
/// map.insert(8, "c");
163-
///
164-
/// for (key, value) in map.range((Excluded(3), Included(8))) {
165-
/// println!("{}: {}", key, value);
166-
/// }
167-
///
168-
/// assert_eq!(Some((&3, &"a")), map.range((Unbounded, Included(5))).next());
169-
/// ```
170-
///
171-
/// [`BTreeMap::range`]: btree_map/struct.BTreeMap.html#method.range
172135
#[stable(feature = "collections_bound", since = "1.17.0")]
173-
#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq)]
174-
pub enum Bound<T> {
175-
/// An inclusive bound.
176-
#[stable(feature = "collections_bound", since = "1.17.0")]
177-
Included(T),
178-
/// An exclusive bound.
179-
#[stable(feature = "collections_bound", since = "1.17.0")]
180-
Excluded(T),
181-
/// An infinite endpoint. Indicates that there is no bound in this direction.
182-
#[stable(feature = "collections_bound", since = "1.17.0")]
183-
Unbounded,
184-
}
136+
pub use core::collections::Bound;
185137

186138
/// An intermediate trait for specialization of `Extend`.
187139
#[doc(hidden)]

src/libcore/collections.rs

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
//! Collection types.
2+
//!
3+
//! See [`std::collections`](../std/collections/index.html) for a detailed
4+
//! discussion of collections in Rust.
5+
6+
/// An endpoint of a range of keys.
7+
///
8+
/// # Examples
9+
///
10+
/// `Bound`s are range endpoints:
11+
///
12+
/// ```
13+
/// #![feature(collections_range)]
14+
///
15+
/// use std::collections::range::RangeArgument;
16+
/// use std::collections::Bound::*;
17+
///
18+
/// assert_eq!((..100).start(), Unbounded);
19+
/// assert_eq!((1..12).start(), Included(&1));
20+
/// assert_eq!((1..12).end(), Excluded(&12));
21+
/// ```
22+
///
23+
/// Using a tuple of `Bound`s as an argument to [`BTreeMap::range`].
24+
/// Note that in most cases, it's better to use range syntax (`1..5`) instead.
25+
///
26+
/// ```
27+
/// use std::collections::BTreeMap;
28+
/// use std::collections::Bound::{Excluded, Included, Unbounded};
29+
///
30+
/// let mut map = BTreeMap::new();
31+
/// map.insert(3, "a");
32+
/// map.insert(5, "b");
33+
/// map.insert(8, "c");
34+
///
35+
/// for (key, value) in map.range((Excluded(3), Included(8))) {
36+
/// println!("{}: {}", key, value);
37+
/// }
38+
///
39+
/// assert_eq!(Some((&3, &"a")), map.range((Unbounded, Included(5))).next());
40+
/// ```
41+
///
42+
/// [`BTreeMap::range`]: btree_map/struct.BTreeMap.html#method.range
43+
#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq)]
44+
#[stable(feature = "collections_bound", since = "1.17.0")]
45+
pub enum Bound<T> {
46+
/// An inclusive bound.
47+
#[stable(feature = "collections_bound", since = "1.17.0")]
48+
Included(T),
49+
/// An exclusive bound.
50+
#[stable(feature = "collections_bound", since = "1.17.0")]
51+
Excluded(T),
52+
/// An infinite endpoint. Indicates that there is no bound in this direction.
53+
#[stable(feature = "collections_bound", since = "1.17.0")]
54+
Unbounded,
55+
}

src/libcore/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,9 @@ pub mod str;
171171
pub mod hash;
172172
pub mod fmt;
173173

174+
#[unstable(feature = "core_bound", issue = "0")]
175+
pub mod collections;
176+
174177
// note: does not need to be public
175178
mod char_private;
176179
mod iter_private;

0 commit comments

Comments
 (0)