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