]> git.lizzy.rs Git - rust.git/blob - src/libcollections/lib.rs
ce00bd48bb8baf321092b8bf8acdcc375f7a066c
[rust.git] / src / libcollections / lib.rs
1 // Copyright 2013-2014 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) for a detailed discussion of collections in Rust.
14
15
16 #![crate_name = "collections"]
17 #![unstable(feature = "collections")]
18 #![staged_api]
19 #![crate_type = "rlib"]
20 #![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
21        html_favicon_url = "http://www.rust-lang.org/favicon.ico",
22        html_root_url = "http://doc.rust-lang.org/nightly/",
23        html_playground_url = "http://play.rust-lang.org/")]
24
25 #![cfg_attr(not(stage0), allow(unused_mut))] // NOTE: remove after stage0 snap
26
27 #![feature(alloc)]
28 #![feature(box_syntax)]
29 #![feature(core)]
30 #![feature(hash)]
31 #![feature(int_uint)]
32 #![feature(staged_api)]
33 #![feature(unboxed_closures)]
34 #![feature(unicode)]
35 #![feature(unsafe_destructor, slicing_syntax)]
36 #![cfg_attr(test, feature(test))]
37
38 #![no_std]
39
40 #[macro_use]
41 extern crate core;
42
43 extern crate unicode;
44 extern crate alloc;
45
46 #[cfg(test)] extern crate test;
47 #[cfg(test)] #[macro_use] extern crate std;
48 #[cfg(test)] #[macro_use] extern crate log;
49
50 pub use binary_heap::BinaryHeap;
51 pub use bitv::Bitv;
52 pub use bitv_set::BitvSet;
53 pub use btree_map::BTreeMap;
54 pub use btree_set::BTreeSet;
55 pub use dlist::DList;
56 pub use enum_set::EnumSet;
57 pub use ring_buf::RingBuf;
58 pub use string::String;
59 pub use vec::Vec;
60 pub use vec_map::VecMap;
61
62 // Needed for the vec! macro
63 pub use alloc::boxed;
64
65 #[macro_use]
66 mod macros;
67
68 pub mod binary_heap;
69 mod bit;
70 mod btree;
71 pub mod dlist;
72 pub mod enum_set;
73 pub mod ring_buf;
74 pub mod slice;
75 pub mod str;
76 pub mod string;
77 pub mod vec;
78 pub mod vec_map;
79
80 #[unstable(feature = "collections",
81            reason = "RFC 509")]
82 pub mod bitv {
83     pub use bit::{Bitv, Iter};
84 }
85
86 #[unstable(feature = "collections",
87            reason = "RFC 509")]
88 pub mod bitv_set {
89     pub use bit::{BitvSet, Union, Intersection, Difference, SymmetricDifference};
90     pub use bit::SetIter as Iter;
91 }
92
93 #[stable(feature = "rust1", since = "1.0.0")]
94 pub mod btree_map {
95     pub use btree::map::*;
96 }
97
98 #[stable(feature = "rust1", since = "1.0.0")]
99 pub mod btree_set {
100     pub use btree::set::*;
101 }
102
103
104 #[cfg(test)] mod bench;
105
106 // FIXME(#14344) this shouldn't be necessary
107 #[doc(hidden)]
108 pub fn fixme_14344_be_sure_to_link_to_collections() {}
109
110 #[cfg(not(test))]
111 mod std {
112     pub use core::fmt;      // necessary for panic!()
113     pub use core::option;   // necessary for panic!()
114     pub use core::clone;    // derive(Clone)
115     pub use core::cmp;      // derive(Eq, Ord, etc.)
116     pub use core::marker;   // derive(Copy)
117     pub use core::hash;     // derive(Hash)
118     pub use core::ops;      // RangeFull
119     // for-loops
120     pub use core::iter;
121 }
122
123 #[cfg(test)]
124 mod prelude {
125     // from core.
126     pub use core::borrow::IntoCow;
127     pub use core::clone::Clone;
128     pub use core::cmp::{PartialEq, Eq, PartialOrd, Ord};
129     pub use core::cmp::Ordering::{Less, Equal, Greater};
130     pub use core::iter::range;
131     pub use core::iter::{FromIterator, Extend, IteratorExt};
132     pub use core::iter::{Iterator, DoubleEndedIterator, RandomAccessIterator};
133     pub use core::iter::{ExactSizeIterator};
134     pub use core::marker::{Copy, Send, Sized, Sync};
135     pub use core::mem::drop;
136     pub use core::ops::{Drop, Fn, FnMut, FnOnce};
137     pub use core::option::Option;
138     pub use core::option::Option::{Some, None};
139     pub use core::ptr::PtrExt;
140     pub use core::result::Result;
141     pub use core::result::Result::{Ok, Err};
142
143     // in core and collections (may differ).
144     pub use slice::{AsSlice, SliceExt};
145     pub use str::{Str, StrExt};
146
147     // from other crates.
148     pub use alloc::boxed::Box;
149     pub use unicode::char::CharExt;
150
151     // from collections.
152     pub use slice::SliceConcatExt;
153     pub use string::{String, ToString};
154     pub use vec::Vec;
155 }
156
157 /// An endpoint of a range of keys.
158 pub enum Bound<T> {
159     /// An inclusive bound.
160     Included(T),
161     /// An exclusive bound.
162     Excluded(T),
163     /// An infinite endpoint. Indicates that there is no bound in this direction.
164     Unbounded,
165 }