Skip to content

Commit 121b57b

Browse files
committed
Move some alloc crate top-level items to a new alloc::collections module
This matches std::collections
1 parent 26324d0 commit 121b57b

File tree

12 files changed

+69
-46
lines changed

12 files changed

+69
-46
lines changed
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

src/liballoc/btree/set.rs renamed to src/liballoc/collections/btree/set.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use core::iter::{Peekable, FromIterator, FusedIterator};
1919
use core::ops::{BitOr, BitAnd, BitXor, Sub, RangeBounds};
2020

2121
use borrow::Borrow;
22-
use btree_map::{BTreeMap, Keys};
22+
use collections::btree_map::{self, BTreeMap, Keys};
2323
use super::Recover;
2424

2525
// FIXME(conventions): implement bounded iterators
@@ -104,7 +104,7 @@ impl<'a, T: 'a + fmt::Debug> fmt::Debug for Iter<'a, T> {
104104
#[stable(feature = "rust1", since = "1.0.0")]
105105
#[derive(Debug)]
106106
pub struct IntoIter<T> {
107-
iter: ::btree_map::IntoIter<T, ()>,
107+
iter: btree_map::IntoIter<T, ()>,
108108
}
109109

110110
/// An iterator over a sub-range of items in a `BTreeSet`.
@@ -117,7 +117,7 @@ pub struct IntoIter<T> {
117117
#[derive(Debug)]
118118
#[stable(feature = "btree_range", since = "1.17.0")]
119119
pub struct Range<'a, T: 'a> {
120-
iter: ::btree_map::Range<'a, T, ()>,
120+
iter: btree_map::Range<'a, T, ()>,
121121
}
122122

123123
/// A lazy iterator producing elements in the difference of `BTreeSet`s.
File renamed without changes.

src/liballoc/collections/mod.rs

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
// Copyright 2018 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+
#![stable(feature = "rust1", since = "1.0.0")]
14+
15+
pub mod binary_heap;
16+
mod btree;
17+
pub mod linked_list;
18+
pub mod vec_deque;
19+
20+
#[stable(feature = "rust1", since = "1.0.0")]
21+
pub mod btree_map {
22+
//! A map based on a B-Tree.
23+
#[stable(feature = "rust1", since = "1.0.0")]
24+
pub use super::btree::map::*;
25+
}
26+
27+
#[stable(feature = "rust1", since = "1.0.0")]
28+
pub mod btree_set {
29+
//! A set based on a B-Tree.
30+
#[stable(feature = "rust1", since = "1.0.0")]
31+
pub use super::btree::set::*;
32+
}
33+
34+
#[stable(feature = "rust1", since = "1.0.0")]
35+
#[doc(no_inline)]
36+
pub use self::binary_heap::BinaryHeap;
37+
38+
#[stable(feature = "rust1", since = "1.0.0")]
39+
#[doc(no_inline)]
40+
pub use self::btree_map::BTreeMap;
41+
42+
#[stable(feature = "rust1", since = "1.0.0")]
43+
#[doc(no_inline)]
44+
pub use self::btree_set::BTreeSet;
45+
46+
#[stable(feature = "rust1", since = "1.0.0")]
47+
#[doc(no_inline)]
48+
pub use self::linked_list::LinkedList;
49+
50+
#[stable(feature = "rust1", since = "1.0.0")]
51+
#[doc(no_inline)]
52+
pub use self::vec_deque::VecDeque;
53+
54+
/// An intermediate trait for specialization of `Extend`.
55+
#[doc(hidden)]
56+
trait SpecExtend<I: IntoIterator> {
57+
/// Extends `self` with the contents of the given iterator.
58+
fn spec_extend(&mut self, iter: I);
59+
}

src/liballoc/vec_deque.rs renamed to src/liballoc/collections/vec_deque.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2891,7 +2891,7 @@ mod tests {
28912891

28922892
#[test]
28932893
fn test_from_vec() {
2894-
use super::super::vec::Vec;
2894+
use vec::Vec;
28952895
for cap in 0..35 {
28962896
for len in 0..cap + 1 {
28972897
let mut vec = Vec::with_capacity(cap);
@@ -2907,7 +2907,7 @@ mod tests {
29072907

29082908
#[test]
29092909
fn test_vec_from_vecdeque() {
2910-
use super::super::vec::Vec;
2910+
use vec::Vec;
29112911

29122912
fn create_vec_and_test_convert(cap: usize, offset: usize, len: usize) {
29132913
let mut vd = VecDeque::with_capacity(cap);

src/liballoc/lib.rs

+1-36
Original file line numberDiff line numberDiff line change
@@ -162,59 +162,24 @@ mod boxed {
162162
}
163163
#[cfg(test)]
164164
mod boxed_test;
165+
pub mod collections;
165166
#[cfg(target_has_atomic = "ptr")]
166167
pub mod arc;
167168
pub mod rc;
168169
pub mod raw_vec;
169170

170-
// collections modules
171-
pub mod binary_heap;
172-
mod btree;
173171
pub mod borrow;
174172
pub mod fmt;
175-
pub mod linked_list;
176173
pub mod slice;
177174
pub mod str;
178175
pub mod string;
179176
pub mod vec;
180-
pub mod vec_deque;
181-
182-
#[stable(feature = "rust1", since = "1.0.0")]
183-
pub mod btree_map {
184-
//! A map based on a B-Tree.
185-
#[stable(feature = "rust1", since = "1.0.0")]
186-
pub use btree::map::*;
187-
}
188-
189-
#[stable(feature = "rust1", since = "1.0.0")]
190-
pub mod btree_set {
191-
//! A set based on a B-Tree.
192-
#[stable(feature = "rust1", since = "1.0.0")]
193-
pub use btree::set::*;
194-
}
195177

196178
#[cfg(not(test))]
197179
mod std {
198180
pub use core::ops; // RangeFull
199181
}
200182

201-
/// An intermediate trait for specialization of `Extend`.
202-
#[doc(hidden)]
203-
trait SpecExtend<I: IntoIterator> {
204-
/// Extends `self` with the contents of the given iterator.
205-
fn spec_extend(&mut self, iter: I);
206-
}
207-
208-
#[doc(no_inline)]
209-
pub use binary_heap::BinaryHeap;
210-
#[doc(no_inline)]
211-
pub use btree_map::BTreeMap;
212-
#[doc(no_inline)]
213-
pub use btree_set::BTreeSet;
214-
#[doc(no_inline)]
215-
pub use linked_list::LinkedList;
216-
#[doc(no_inline)]
217-
pub use vec_deque::VecDeque;
218183
#[doc(no_inline)]
219184
pub use string::String;
220185
#[doc(no_inline)]

src/liballoc/str.rs

-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ use boxed::Box;
5151
use slice::{SliceConcatExt, SliceIndex};
5252
use string::String;
5353
use vec::Vec;
54-
use vec_deque::VecDeque;
5554

5655
#[stable(feature = "rust1", since = "1.0.0")]
5756
pub use core::str::{FromStr, Utf8Error};

src/libstd/collections/mod.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -424,13 +424,13 @@
424424
#[doc(hidden)]
425425
pub use ops::Bound;
426426
#[stable(feature = "rust1", since = "1.0.0")]
427-
pub use alloc_crate::{BinaryHeap, BTreeMap, BTreeSet};
427+
pub use alloc_crate::collections::{BinaryHeap, BTreeMap, BTreeSet};
428428
#[stable(feature = "rust1", since = "1.0.0")]
429-
pub use alloc_crate::{LinkedList, VecDeque};
429+
pub use alloc_crate::collections::{LinkedList, VecDeque};
430430
#[stable(feature = "rust1", since = "1.0.0")]
431-
pub use alloc_crate::{binary_heap, btree_map, btree_set};
431+
pub use alloc_crate::collections::{binary_heap, btree_map, btree_set};
432432
#[stable(feature = "rust1", since = "1.0.0")]
433-
pub use alloc_crate::{linked_list, vec_deque};
433+
pub use alloc_crate::collections::{linked_list, vec_deque};
434434

435435
#[stable(feature = "rust1", since = "1.0.0")]
436436
pub use self::hash_map::HashMap;

0 commit comments

Comments
 (0)