]> git.lizzy.rs Git - rust.git/blob - src/liballoc/collections/mod.rs
Rollup merge of #67875 - dtolnay:hidden, r=GuillaumeGomez
[rust.git] / src / liballoc / collections / mod.rs
1 //! Collection types.
2
3 #![stable(feature = "rust1", since = "1.0.0")]
4
5 pub mod binary_heap;
6 mod btree;
7 pub mod linked_list;
8 pub mod vec_deque;
9
10 #[stable(feature = "rust1", since = "1.0.0")]
11 pub mod btree_map {
12     //! A map based on a B-Tree.
13     #[stable(feature = "rust1", since = "1.0.0")]
14     pub use super::btree::map::*;
15 }
16
17 #[stable(feature = "rust1", since = "1.0.0")]
18 pub mod btree_set {
19     //! A set based on a B-Tree.
20     #[stable(feature = "rust1", since = "1.0.0")]
21     pub use super::btree::set::*;
22 }
23
24 #[stable(feature = "rust1", since = "1.0.0")]
25 #[doc(no_inline)]
26 pub use binary_heap::BinaryHeap;
27
28 #[stable(feature = "rust1", since = "1.0.0")]
29 #[doc(no_inline)]
30 pub use btree_map::BTreeMap;
31
32 #[stable(feature = "rust1", since = "1.0.0")]
33 #[doc(no_inline)]
34 pub use btree_set::BTreeSet;
35
36 #[stable(feature = "rust1", since = "1.0.0")]
37 #[doc(no_inline)]
38 pub use linked_list::LinkedList;
39
40 #[stable(feature = "rust1", since = "1.0.0")]
41 #[doc(no_inline)]
42 pub use vec_deque::VecDeque;
43
44 use crate::alloc::{Layout, LayoutErr};
45
46 /// The error type for `try_reserve` methods.
47 #[derive(Clone, PartialEq, Eq, Debug)]
48 #[unstable(feature = "try_reserve", reason = "new API", issue = "48043")]
49 pub enum TryReserveError {
50     /// Error due to the computed capacity exceeding the collection's maximum
51     /// (usually `isize::MAX` bytes).
52     CapacityOverflow,
53
54     /// The memory allocator returned an error
55     AllocError {
56         /// The layout of allocation request that failed
57         layout: Layout,
58
59         #[doc(hidden)]
60         #[unstable(
61             feature = "container_error_extra",
62             issue = "none",
63             reason = "\
64             Enable exposing the allocator’s custom error value \
65             if an associated type is added in the future: \
66             https://github.com/rust-lang/wg-allocators/issues/23"
67         )]
68         non_exhaustive: (),
69     },
70 }
71
72 #[unstable(feature = "try_reserve", reason = "new API", issue = "48043")]
73 impl From<LayoutErr> for TryReserveError {
74     #[inline]
75     fn from(_: LayoutErr) -> Self {
76         TryReserveError::CapacityOverflow
77     }
78 }
79
80 /// An intermediate trait for specialization of `Extend`.
81 #[doc(hidden)]
82 trait SpecExtend<I: IntoIterator> {
83     /// Extends `self` with the contents of the given iterator.
84     fn spec_extend(&mut self, iter: I);
85 }