3 #![stable(feature = "rust1", since = "1.0.0")]
10 #[stable(feature = "rust1", since = "1.0.0")]
12 //! A map based on a B-Tree.
13 #[stable(feature = "rust1", since = "1.0.0")]
14 pub use super::btree::map::*;
17 #[stable(feature = "rust1", since = "1.0.0")]
19 //! A set based on a B-Tree.
20 #[stable(feature = "rust1", since = "1.0.0")]
21 pub use super::btree::set::*;
24 #[stable(feature = "rust1", since = "1.0.0")]
26 pub use binary_heap::BinaryHeap;
28 #[stable(feature = "rust1", since = "1.0.0")]
30 pub use btree_map::BTreeMap;
32 #[stable(feature = "rust1", since = "1.0.0")]
34 pub use btree_set::BTreeSet;
36 #[stable(feature = "rust1", since = "1.0.0")]
38 pub use linked_list::LinkedList;
40 #[stable(feature = "rust1", since = "1.0.0")]
42 pub use vec_deque::VecDeque;
44 use crate::alloc::{Layout, LayoutErr};
45 use core::fmt::Display;
47 /// The error type for `try_reserve` methods.
48 #[derive(Clone, PartialEq, Eq, Debug)]
49 #[unstable(feature = "try_reserve", reason = "new API", issue = "48043")]
50 pub enum TryReserveError {
51 /// Error due to the computed capacity exceeding the collection's maximum
52 /// (usually `isize::MAX` bytes).
55 /// The memory allocator returned an error
57 /// The layout of allocation request that failed
62 feature = "container_error_extra",
65 Enable exposing the allocator’s custom error value \
66 if an associated type is added in the future: \
67 https://github.com/rust-lang/wg-allocators/issues/23"
73 #[unstable(feature = "try_reserve", reason = "new API", issue = "48043")]
74 impl From<LayoutErr> for TryReserveError {
76 fn from(_: LayoutErr) -> Self {
77 TryReserveError::CapacityOverflow
81 #[unstable(feature = "try_reserve", reason = "new API", issue = "48043")]
82 impl Display for TryReserveError {
85 fmt: &mut core::fmt::Formatter<'_>,
86 ) -> core::result::Result<(), core::fmt::Error> {
87 fmt.write_str("memory allocation failed")?;
88 let reason = match &self {
89 TryReserveError::CapacityOverflow => {
90 " because the computed capacity exceeded the collection's maximum"
92 TryReserveError::AllocError { .. } => " because the memory allocator returned a error",
98 /// An intermediate trait for specialization of `Extend`.
100 trait SpecExtend<I: IntoIterator> {
101 /// Extends `self` with the contents of the given iterator.
102 fn spec_extend(&mut self, iter: I);