Skip to content

Commit 95fc6cc

Browse files
author
Clar Charr
committed
Move Bound to libcore.
1 parent a8dc246 commit 95fc6cc

File tree

5 files changed

+84
-50
lines changed

5 files changed

+84
-50
lines changed

src/doc/unstable-book/src/SUMMARY.md

+1
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@
106106
- [c_void_variant](library-features/c-void-variant.md)
107107
- [char_escape_debug](library-features/char-escape-debug.md)
108108
- [coerce_unsized](library-features/coerce-unsized.md)
109+
- [core_collections](library-features/core-collections.md)
109110
- [collection_placement](library-features/collection-placement.md)
110111
- [collections_range](library-features/collections-range.md)
111112
- [collections](library-features/collections.md)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# `core_collections`
2+
3+
The tracking issue for this feature is: [#0]
4+
5+
[#0]: https://github.com/rust-lang/rust/issues/0
6+
7+
------------------------

src/libcollections/lib.rs

+2-50
Original file line numberDiff line numberDiff line change
@@ -130,59 +130,11 @@ pub mod btree_set {
130130

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

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

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

src/libcore/collections.rs

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
//! Collection types.
12+
//!
13+
//! See [`std::collections`](../../std/collections/index.html) for a detailed
14+
//! discussion of collections in Rust.
15+
16+
/// An endpoint of a range of keys.
17+
///
18+
/// # Examples
19+
///
20+
/// `Bound`s are range endpoints:
21+
///
22+
/// ```
23+
/// #![feature(collections_range)]
24+
///
25+
/// use std::collections::range::RangeArgument;
26+
/// use std::collections::Bound::*;
27+
///
28+
/// assert_eq!((..100).start(), Unbounded);
29+
/// assert_eq!((1..12).start(), Included(&1));
30+
/// assert_eq!((1..12).end(), Excluded(&12));
31+
/// ```
32+
///
33+
/// Using a tuple of `Bound`s as an argument to [`BTreeMap::range`].
34+
/// Note that in most cases, it's better to use range syntax (`1..5`) instead.
35+
///
36+
/// ```
37+
/// use std::collections::BTreeMap;
38+
/// use std::collections::Bound::{Excluded, Included, Unbounded};
39+
///
40+
/// let mut map = BTreeMap::new();
41+
/// map.insert(3, "a");
42+
/// map.insert(5, "b");
43+
/// map.insert(8, "c");
44+
///
45+
/// for (key, value) in map.range((Excluded(3), Included(8))) {
46+
/// println!("{}: {}", key, value);
47+
/// }
48+
///
49+
/// assert_eq!(Some((&3, &"a")), map.range((Unbounded, Included(5))).next());
50+
/// ```
51+
///
52+
/// [`BTreeMap::range`]: ../../collections/btree_map/struct.BTreeMap.html#method.range
53+
#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq)]
54+
#[stable(feature = "collections_bound", since = "1.17.0")]
55+
pub enum Bound<T> {
56+
/// An inclusive bound.
57+
#[stable(feature = "collections_bound", since = "1.17.0")]
58+
Included(
59+
#[stable(feature = "collections_bound", since = "1.17.0")] // ???
60+
T
61+
),
62+
/// An exclusive bound.
63+
#[stable(feature = "collections_bound", since = "1.17.0")]
64+
Excluded(
65+
#[stable(feature = "collections_bound", since = "1.17.0")] // ???
66+
T
67+
),
68+
/// An infinite endpoint. Indicates that there is no bound in this direction.
69+
#[stable(feature = "collections_bound", since = "1.17.0")]
70+
Unbounded,
71+
}

src/libcore/lib.rs

+3
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_collections", 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)