Move core::alloc::CollectionAllocErr to alloc::collections
This commit is contained in:
parent
121b57b87a
commit
b0547cea0a
9 changed files with 38 additions and 36 deletions
|
@ -51,6 +51,35 @@ pub use self::linked_list::LinkedList;
|
||||||
#[doc(no_inline)]
|
#[doc(no_inline)]
|
||||||
pub use self::vec_deque::VecDeque;
|
pub use self::vec_deque::VecDeque;
|
||||||
|
|
||||||
|
use alloc::{AllocErr, LayoutErr};
|
||||||
|
|
||||||
|
/// Augments `AllocErr` with a CapacityOverflow variant.
|
||||||
|
#[derive(Clone, PartialEq, Eq, Debug)]
|
||||||
|
#[unstable(feature = "try_reserve", reason = "new API", issue="48043")]
|
||||||
|
pub enum CollectionAllocErr {
|
||||||
|
/// Error due to the computed capacity exceeding the collection's maximum
|
||||||
|
/// (usually `isize::MAX` bytes).
|
||||||
|
CapacityOverflow,
|
||||||
|
/// Error due to the allocator (see the `AllocErr` type's docs).
|
||||||
|
AllocErr,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[unstable(feature = "try_reserve", reason = "new API", issue="48043")]
|
||||||
|
impl From<AllocErr> for CollectionAllocErr {
|
||||||
|
#[inline]
|
||||||
|
fn from(AllocErr: AllocErr) -> Self {
|
||||||
|
CollectionAllocErr::AllocErr
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[unstable(feature = "try_reserve", reason = "new API", issue="48043")]
|
||||||
|
impl From<LayoutErr> for CollectionAllocErr {
|
||||||
|
#[inline]
|
||||||
|
fn from(_: LayoutErr) -> Self {
|
||||||
|
CollectionAllocErr::CapacityOverflow
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// An intermediate trait for specialization of `Extend`.
|
/// An intermediate trait for specialization of `Extend`.
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
trait SpecExtend<I: IntoIterator> {
|
trait SpecExtend<I: IntoIterator> {
|
||||||
|
|
|
@ -30,7 +30,7 @@ use core::slice;
|
||||||
use core::hash::{Hash, Hasher};
|
use core::hash::{Hash, Hasher};
|
||||||
use core::cmp;
|
use core::cmp;
|
||||||
|
|
||||||
use alloc::CollectionAllocErr;
|
use collections::CollectionAllocErr;
|
||||||
use raw_vec::RawVec;
|
use raw_vec::RawVec;
|
||||||
use vec::Vec;
|
use vec::Vec;
|
||||||
|
|
||||||
|
|
|
@ -18,8 +18,8 @@ use core::ptr::{self, NonNull, Unique};
|
||||||
use core::slice;
|
use core::slice;
|
||||||
|
|
||||||
use alloc::{Alloc, Layout, Global, handle_alloc_error};
|
use alloc::{Alloc, Layout, Global, handle_alloc_error};
|
||||||
use alloc::CollectionAllocErr;
|
use collections::CollectionAllocErr;
|
||||||
use alloc::CollectionAllocErr::*;
|
use collections::CollectionAllocErr::*;
|
||||||
use boxed::Box;
|
use boxed::Box;
|
||||||
|
|
||||||
/// A low-level utility for more ergonomically allocating, reallocating, and deallocating
|
/// A low-level utility for more ergonomically allocating, reallocating, and deallocating
|
||||||
|
|
|
@ -66,7 +66,7 @@ use core::ptr;
|
||||||
use core::str::pattern::Pattern;
|
use core::str::pattern::Pattern;
|
||||||
use core::str::lossy;
|
use core::str::lossy;
|
||||||
|
|
||||||
use alloc::CollectionAllocErr;
|
use collections::CollectionAllocErr;
|
||||||
use borrow::{Cow, ToOwned};
|
use borrow::{Cow, ToOwned};
|
||||||
use boxed::Box;
|
use boxed::Box;
|
||||||
use str::{self, from_boxed_utf8_unchecked, FromStr, Utf8Error, Chars};
|
use str::{self, from_boxed_utf8_unchecked, FromStr, Utf8Error, Chars};
|
||||||
|
|
|
@ -80,7 +80,7 @@ use core::ptr;
|
||||||
use core::ptr::NonNull;
|
use core::ptr::NonNull;
|
||||||
use core::slice;
|
use core::slice;
|
||||||
|
|
||||||
use alloc::CollectionAllocErr;
|
use collections::CollectionAllocErr;
|
||||||
use borrow::ToOwned;
|
use borrow::ToOwned;
|
||||||
use borrow::Cow;
|
use borrow::Cow;
|
||||||
use boxed::Box;
|
use boxed::Box;
|
||||||
|
|
|
@ -385,34 +385,6 @@ impl fmt::Display for CannotReallocInPlace {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Augments `AllocErr` with a CapacityOverflow variant.
|
|
||||||
// FIXME: should this be in libcore or liballoc?
|
|
||||||
#[derive(Clone, PartialEq, Eq, Debug)]
|
|
||||||
#[unstable(feature = "try_reserve", reason = "new API", issue="48043")]
|
|
||||||
pub enum CollectionAllocErr {
|
|
||||||
/// Error due to the computed capacity exceeding the collection's maximum
|
|
||||||
/// (usually `isize::MAX` bytes).
|
|
||||||
CapacityOverflow,
|
|
||||||
/// Error due to the allocator (see the `AllocErr` type's docs).
|
|
||||||
AllocErr,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[unstable(feature = "try_reserve", reason = "new API", issue="48043")]
|
|
||||||
impl From<AllocErr> for CollectionAllocErr {
|
|
||||||
#[inline]
|
|
||||||
fn from(AllocErr: AllocErr) -> Self {
|
|
||||||
CollectionAllocErr::AllocErr
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[unstable(feature = "try_reserve", reason = "new API", issue="48043")]
|
|
||||||
impl From<LayoutErr> for CollectionAllocErr {
|
|
||||||
#[inline]
|
|
||||||
fn from(_: LayoutErr) -> Self {
|
|
||||||
CollectionAllocErr::CapacityOverflow
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// A memory allocator that can be registered as the standard library’s default
|
/// A memory allocator that can be registered as the standard library’s default
|
||||||
/// though the `#[global_allocator]` attributes.
|
/// though the `#[global_allocator]` attributes.
|
||||||
///
|
///
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
use self::Entry::*;
|
use self::Entry::*;
|
||||||
use self::VacantEntryState::*;
|
use self::VacantEntryState::*;
|
||||||
|
|
||||||
use alloc::CollectionAllocErr;
|
use collections::CollectionAllocErr;
|
||||||
use cell::Cell;
|
use cell::Cell;
|
||||||
use borrow::Borrow;
|
use borrow::Borrow;
|
||||||
use cmp::max;
|
use cmp::max;
|
||||||
|
|
|
@ -8,7 +8,8 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
use alloc::{Global, Alloc, Layout, LayoutErr, CollectionAllocErr, handle_alloc_error};
|
use alloc::{Global, Alloc, Layout, LayoutErr, handle_alloc_error};
|
||||||
|
use collections::CollectionAllocErr;
|
||||||
use hash::{BuildHasher, Hash, Hasher};
|
use hash::{BuildHasher, Hash, Hasher};
|
||||||
use marker;
|
use marker;
|
||||||
use mem::{size_of, needs_drop};
|
use mem::{size_of, needs_drop};
|
||||||
|
|
|
@ -438,7 +438,7 @@ pub use self::hash_map::HashMap;
|
||||||
pub use self::hash_set::HashSet;
|
pub use self::hash_set::HashSet;
|
||||||
|
|
||||||
#[unstable(feature = "try_reserve", reason = "new API", issue="48043")]
|
#[unstable(feature = "try_reserve", reason = "new API", issue="48043")]
|
||||||
pub use alloc::CollectionAllocErr;
|
pub use alloc_crate::collections::CollectionAllocErr;
|
||||||
|
|
||||||
mod hash;
|
mod hash;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue