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 mod raw_vec;
14 
15 pub mod vec;
16 pub use self::vec::Vec;
17 
18 mod str;
19 pub mod string;
20 pub use self::string::String;
21 
22 // pub mod binary_heap;
23 // mod btree;
24 // pub mod linked_list;
25 // pub mod vec_deque;
26 
27 // pub mod btree_map {
28 //     //! A map based on a B-Tree.
29 //     pub use super::btree::map::*;
30 // }
31 
32 // pub mod btree_set {
33 //     //! A set based on a B-Tree.
34 //     pub use super::btree::set::*;
35 // }
36 
37 // #[doc(no_inline)]
38 // pub use self::binary_heap::BinaryHeap;
39 
40 // #[doc(no_inline)]
41 // pub use self::btree_map::BTreeMap;
42 
43 // #[doc(no_inline)]
44 // pub use self::btree_set::BTreeSet;
45 
46 // #[doc(no_inline)]
47 // pub use self::linked_list::LinkedList;
48 
49 // #[doc(no_inline)]
50 // pub use self::vec_deque::VecDeque;
51 
52 use crate::alloc::{AllocErr, LayoutErr};
53 
54 /// Augments `AllocErr` with a CapacityOverflow variant.
55 #[derive(Clone, PartialEq, Eq, Debug)]
56 // #[unstable(feature = "try_reserve", reason = "new API", issue="48043")]
57 pub enum CollectionAllocErr {
58     /// Error due to the computed capacity exceeding the collection's maximum
59     /// (usually `isize::MAX` bytes).
60     CapacityOverflow,
61     /// Error due to the allocator (see the `AllocErr` type's docs).
62     AllocErr,
63 }
64 
65 // #[unstable(feature = "try_reserve", reason = "new API", issue="48043")]
66 impl From<AllocErr> for CollectionAllocErr {
67     #[inline]
from(AllocErr: AllocErr) -> Self68     fn from(AllocErr: AllocErr) -> Self {
69         CollectionAllocErr::AllocErr
70     }
71 }
72 
73 // #[unstable(feature = "try_reserve", reason = "new API", issue="48043")]
74 impl From<LayoutErr> for CollectionAllocErr {
75     #[inline]
from(_: LayoutErr) -> Self76     fn from(_: LayoutErr) -> Self {
77         CollectionAllocErr::CapacityOverflow
78     }
79 }
80 
81 // /// An intermediate trait for specialization of `Extend`.
82 // #[doc(hidden)]
83 // trait SpecExtend<I: IntoIterator> {
84 //     /// Extends `self` with the contents of the given iterator.
85 //     fn spec_extend(&mut self, iter: I);
86 // }
87