Rename CollectionAllocError to TryReserveError
This commit is contained in:
parent
9dd5c19199
commit
36b18a1901
11 changed files with 45 additions and 45 deletions
|
@ -46,7 +46,7 @@ use crate::alloc::{AllocErr, LayoutErr};
|
||||||
/// Augments `AllocErr` with a CapacityOverflow variant.
|
/// Augments `AllocErr` with a CapacityOverflow variant.
|
||||||
#[derive(Clone, PartialEq, Eq, Debug)]
|
#[derive(Clone, PartialEq, Eq, Debug)]
|
||||||
#[unstable(feature = "try_reserve", reason = "new API", issue="48043")]
|
#[unstable(feature = "try_reserve", reason = "new API", issue="48043")]
|
||||||
pub enum CollectionAllocErr {
|
pub enum TryReserveError {
|
||||||
/// Error due to the computed capacity exceeding the collection's maximum
|
/// Error due to the computed capacity exceeding the collection's maximum
|
||||||
/// (usually `isize::MAX` bytes).
|
/// (usually `isize::MAX` bytes).
|
||||||
CapacityOverflow,
|
CapacityOverflow,
|
||||||
|
@ -55,18 +55,18 @@ pub enum CollectionAllocErr {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[unstable(feature = "try_reserve", reason = "new API", issue="48043")]
|
#[unstable(feature = "try_reserve", reason = "new API", issue="48043")]
|
||||||
impl From<AllocErr> for CollectionAllocErr {
|
impl From<AllocErr> for TryReserveError {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn from(AllocErr: AllocErr) -> Self {
|
fn from(AllocErr: AllocErr) -> Self {
|
||||||
CollectionAllocErr::AllocErr
|
TryReserveError::AllocErr
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[unstable(feature = "try_reserve", reason = "new API", issue="48043")]
|
#[unstable(feature = "try_reserve", reason = "new API", issue="48043")]
|
||||||
impl From<LayoutErr> for CollectionAllocErr {
|
impl From<LayoutErr> for TryReserveError {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn from(_: LayoutErr) -> Self {
|
fn from(_: LayoutErr) -> Self {
|
||||||
CollectionAllocErr::CapacityOverflow
|
TryReserveError::CapacityOverflow
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@ use core::ptr::{self, NonNull};
|
||||||
use core::slice;
|
use core::slice;
|
||||||
use core::hash::{Hash, Hasher};
|
use core::hash::{Hash, Hasher};
|
||||||
|
|
||||||
use crate::collections::CollectionAllocErr;
|
use crate::collections::TryReserveError;
|
||||||
use crate::raw_vec::RawVec;
|
use crate::raw_vec::RawVec;
|
||||||
use crate::vec::Vec;
|
use crate::vec::Vec;
|
||||||
|
|
||||||
|
@ -576,10 +576,10 @@ impl<T> VecDeque<T> {
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// #![feature(try_reserve)]
|
/// #![feature(try_reserve)]
|
||||||
/// use std::collections::CollectionAllocErr;
|
/// use std::collections::TryReserveError;
|
||||||
/// use std::collections::VecDeque;
|
/// use std::collections::VecDeque;
|
||||||
///
|
///
|
||||||
/// fn process_data(data: &[u32]) -> Result<VecDeque<u32>, CollectionAllocErr> {
|
/// fn process_data(data: &[u32]) -> Result<VecDeque<u32>, TryReserveError> {
|
||||||
/// let mut output = VecDeque::new();
|
/// let mut output = VecDeque::new();
|
||||||
///
|
///
|
||||||
/// // Pre-reserve the memory, exiting if we can't
|
/// // Pre-reserve the memory, exiting if we can't
|
||||||
|
@ -595,7 +595,7 @@ impl<T> VecDeque<T> {
|
||||||
/// # process_data(&[1, 2, 3]).expect("why is the test harness OOMing on 12 bytes?");
|
/// # process_data(&[1, 2, 3]).expect("why is the test harness OOMing on 12 bytes?");
|
||||||
/// ```
|
/// ```
|
||||||
#[unstable(feature = "try_reserve", reason = "new API", issue="48043")]
|
#[unstable(feature = "try_reserve", reason = "new API", issue="48043")]
|
||||||
pub fn try_reserve_exact(&mut self, additional: usize) -> Result<(), CollectionAllocErr> {
|
pub fn try_reserve_exact(&mut self, additional: usize) -> Result<(), TryReserveError> {
|
||||||
self.try_reserve(additional)
|
self.try_reserve(additional)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -614,10 +614,10 @@ impl<T> VecDeque<T> {
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// #![feature(try_reserve)]
|
/// #![feature(try_reserve)]
|
||||||
/// use std::collections::CollectionAllocErr;
|
/// use std::collections::TryReserveError;
|
||||||
/// use std::collections::VecDeque;
|
/// use std::collections::VecDeque;
|
||||||
///
|
///
|
||||||
/// fn process_data(data: &[u32]) -> Result<VecDeque<u32>, CollectionAllocErr> {
|
/// fn process_data(data: &[u32]) -> Result<VecDeque<u32>, TryReserveError> {
|
||||||
/// let mut output = VecDeque::new();
|
/// let mut output = VecDeque::new();
|
||||||
///
|
///
|
||||||
/// // Pre-reserve the memory, exiting if we can't
|
/// // Pre-reserve the memory, exiting if we can't
|
||||||
|
@ -633,12 +633,12 @@ impl<T> VecDeque<T> {
|
||||||
/// # process_data(&[1, 2, 3]).expect("why is the test harness OOMing on 12 bytes?");
|
/// # process_data(&[1, 2, 3]).expect("why is the test harness OOMing on 12 bytes?");
|
||||||
/// ```
|
/// ```
|
||||||
#[unstable(feature = "try_reserve", reason = "new API", issue="48043")]
|
#[unstable(feature = "try_reserve", reason = "new API", issue="48043")]
|
||||||
pub fn try_reserve(&mut self, additional: usize) -> Result<(), CollectionAllocErr> {
|
pub fn try_reserve(&mut self, additional: usize) -> Result<(), TryReserveError> {
|
||||||
let old_cap = self.cap();
|
let old_cap = self.cap();
|
||||||
let used_cap = self.len() + 1;
|
let used_cap = self.len() + 1;
|
||||||
let new_cap = used_cap.checked_add(additional)
|
let new_cap = used_cap.checked_add(additional)
|
||||||
.and_then(|needed_cap| needed_cap.checked_next_power_of_two())
|
.and_then(|needed_cap| needed_cap.checked_next_power_of_two())
|
||||||
.ok_or(CollectionAllocErr::CapacityOverflow)?;
|
.ok_or(TryReserveError::CapacityOverflow)?;
|
||||||
|
|
||||||
if new_cap > old_cap {
|
if new_cap > old_cap {
|
||||||
self.buf.try_reserve_exact(used_cap, new_cap - used_cap)?;
|
self.buf.try_reserve_exact(used_cap, new_cap - used_cap)?;
|
||||||
|
|
|
@ -8,7 +8,7 @@ use core::ptr::{self, NonNull, Unique};
|
||||||
use core::slice;
|
use core::slice;
|
||||||
|
|
||||||
use crate::alloc::{Alloc, Layout, Global, handle_alloc_error};
|
use crate::alloc::{Alloc, Layout, Global, handle_alloc_error};
|
||||||
use crate::collections::CollectionAllocErr::{self, *};
|
use crate::collections::TryReserveError::{self, *};
|
||||||
use crate::boxed::Box;
|
use crate::boxed::Box;
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
@ -385,7 +385,7 @@ impl<T, A: Alloc> RawVec<T, A> {
|
||||||
|
|
||||||
/// The same as `reserve_exact`, but returns on errors instead of panicking or aborting.
|
/// The same as `reserve_exact`, but returns on errors instead of panicking or aborting.
|
||||||
pub fn try_reserve_exact(&mut self, used_capacity: usize, needed_extra_capacity: usize)
|
pub fn try_reserve_exact(&mut self, used_capacity: usize, needed_extra_capacity: usize)
|
||||||
-> Result<(), CollectionAllocErr> {
|
-> Result<(), TryReserveError> {
|
||||||
|
|
||||||
self.reserve_internal(used_capacity, needed_extra_capacity, Fallible, Exact)
|
self.reserve_internal(used_capacity, needed_extra_capacity, Fallible, Exact)
|
||||||
}
|
}
|
||||||
|
@ -422,7 +422,7 @@ impl<T, A: Alloc> RawVec<T, A> {
|
||||||
/// needed_extra_capacity` elements. This logic is used in amortized reserve methods.
|
/// needed_extra_capacity` elements. This logic is used in amortized reserve methods.
|
||||||
/// Returns `(new_capacity, new_alloc_size)`.
|
/// Returns `(new_capacity, new_alloc_size)`.
|
||||||
fn amortized_new_size(&self, used_capacity: usize, needed_extra_capacity: usize)
|
fn amortized_new_size(&self, used_capacity: usize, needed_extra_capacity: usize)
|
||||||
-> Result<usize, CollectionAllocErr> {
|
-> Result<usize, TryReserveError> {
|
||||||
|
|
||||||
// Nothing we can really do about these checks :(
|
// Nothing we can really do about these checks :(
|
||||||
let required_cap = used_capacity.checked_add(needed_extra_capacity)
|
let required_cap = used_capacity.checked_add(needed_extra_capacity)
|
||||||
|
@ -435,7 +435,7 @@ impl<T, A: Alloc> RawVec<T, A> {
|
||||||
|
|
||||||
/// The same as `reserve`, but returns on errors instead of panicking or aborting.
|
/// The same as `reserve`, but returns on errors instead of panicking or aborting.
|
||||||
pub fn try_reserve(&mut self, used_capacity: usize, needed_extra_capacity: usize)
|
pub fn try_reserve(&mut self, used_capacity: usize, needed_extra_capacity: usize)
|
||||||
-> Result<(), CollectionAllocErr> {
|
-> Result<(), TryReserveError> {
|
||||||
self.reserve_internal(used_capacity, needed_extra_capacity, Fallible, Amortized)
|
self.reserve_internal(used_capacity, needed_extra_capacity, Fallible, Amortized)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -640,7 +640,7 @@ impl<T, A: Alloc> RawVec<T, A> {
|
||||||
needed_extra_capacity: usize,
|
needed_extra_capacity: usize,
|
||||||
fallibility: Fallibility,
|
fallibility: Fallibility,
|
||||||
strategy: ReserveStrategy,
|
strategy: ReserveStrategy,
|
||||||
) -> Result<(), CollectionAllocErr> {
|
) -> Result<(), TryReserveError> {
|
||||||
unsafe {
|
unsafe {
|
||||||
use crate::alloc::AllocErr;
|
use crate::alloc::AllocErr;
|
||||||
|
|
||||||
|
@ -737,7 +737,7 @@ unsafe impl<#[may_dangle] T, A: Alloc> Drop for RawVec<T, A> {
|
||||||
// all 4GB in user-space. e.g., PAE or x32
|
// all 4GB in user-space. e.g., PAE or x32
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn alloc_guard(alloc_size: usize) -> Result<(), CollectionAllocErr> {
|
fn alloc_guard(alloc_size: usize) -> Result<(), TryReserveError> {
|
||||||
if mem::size_of::<usize>() < 8 && alloc_size > core::isize::MAX as usize {
|
if mem::size_of::<usize>() < 8 && alloc_size > core::isize::MAX as usize {
|
||||||
Err(CapacityOverflow)
|
Err(CapacityOverflow)
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -56,7 +56,7 @@ use core::ptr;
|
||||||
use core::str::{pattern::Pattern, lossy};
|
use core::str::{pattern::Pattern, lossy};
|
||||||
|
|
||||||
use crate::borrow::{Cow, ToOwned};
|
use crate::borrow::{Cow, ToOwned};
|
||||||
use crate::collections::CollectionAllocErr;
|
use crate::collections::TryReserveError;
|
||||||
use crate::boxed::Box;
|
use crate::boxed::Box;
|
||||||
use crate::str::{self, from_boxed_utf8_unchecked, FromStr, Utf8Error, Chars};
|
use crate::str::{self, from_boxed_utf8_unchecked, FromStr, Utf8Error, Chars};
|
||||||
use crate::vec::Vec;
|
use crate::vec::Vec;
|
||||||
|
@ -937,9 +937,9 @@ impl String {
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// #![feature(try_reserve)]
|
/// #![feature(try_reserve)]
|
||||||
/// use std::collections::CollectionAllocErr;
|
/// use std::collections::TryReserveError;
|
||||||
///
|
///
|
||||||
/// fn process_data(data: &str) -> Result<String, CollectionAllocErr> {
|
/// fn process_data(data: &str) -> Result<String, TryReserveError> {
|
||||||
/// let mut output = String::new();
|
/// let mut output = String::new();
|
||||||
///
|
///
|
||||||
/// // Pre-reserve the memory, exiting if we can't
|
/// // Pre-reserve the memory, exiting if we can't
|
||||||
|
@ -953,7 +953,7 @@ impl String {
|
||||||
/// # process_data("rust").expect("why is the test harness OOMing on 4 bytes?");
|
/// # process_data("rust").expect("why is the test harness OOMing on 4 bytes?");
|
||||||
/// ```
|
/// ```
|
||||||
#[unstable(feature = "try_reserve", reason = "new API", issue="48043")]
|
#[unstable(feature = "try_reserve", reason = "new API", issue="48043")]
|
||||||
pub fn try_reserve(&mut self, additional: usize) -> Result<(), CollectionAllocErr> {
|
pub fn try_reserve(&mut self, additional: usize) -> Result<(), TryReserveError> {
|
||||||
self.vec.try_reserve(additional)
|
self.vec.try_reserve(additional)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -975,9 +975,9 @@ impl String {
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// #![feature(try_reserve)]
|
/// #![feature(try_reserve)]
|
||||||
/// use std::collections::CollectionAllocErr;
|
/// use std::collections::TryReserveError;
|
||||||
///
|
///
|
||||||
/// fn process_data(data: &str) -> Result<String, CollectionAllocErr> {
|
/// fn process_data(data: &str) -> Result<String, TryReserveError> {
|
||||||
/// let mut output = String::new();
|
/// let mut output = String::new();
|
||||||
///
|
///
|
||||||
/// // Pre-reserve the memory, exiting if we can't
|
/// // Pre-reserve the memory, exiting if we can't
|
||||||
|
@ -991,7 +991,7 @@ impl String {
|
||||||
/// # process_data("rust").expect("why is the test harness OOMing on 4 bytes?");
|
/// # process_data("rust").expect("why is the test harness OOMing on 4 bytes?");
|
||||||
/// ```
|
/// ```
|
||||||
#[unstable(feature = "try_reserve", reason = "new API", issue="48043")]
|
#[unstable(feature = "try_reserve", reason = "new API", issue="48043")]
|
||||||
pub fn try_reserve_exact(&mut self, additional: usize) -> Result<(), CollectionAllocErr> {
|
pub fn try_reserve_exact(&mut self, additional: usize) -> Result<(), TryReserveError> {
|
||||||
self.vec.try_reserve_exact(additional)
|
self.vec.try_reserve_exact(additional)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
use std::collections::CollectionAllocErr::*;
|
use std::collections::TryReserveError::*;
|
||||||
use std::mem::size_of;
|
use std::mem::size_of;
|
||||||
use std::{usize, isize};
|
use std::{usize, isize};
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ use std::borrow::Cow;
|
||||||
use std::mem::size_of;
|
use std::mem::size_of;
|
||||||
use std::{usize, isize};
|
use std::{usize, isize};
|
||||||
use std::vec::{Drain, IntoIter};
|
use std::vec::{Drain, IntoIter};
|
||||||
use std::collections::CollectionAllocErr::*;
|
use std::collections::TryReserveError::*;
|
||||||
|
|
||||||
struct DropCounter<'a> {
|
struct DropCounter<'a> {
|
||||||
count: &'a mut u32,
|
count: &'a mut u32,
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use std::fmt::Debug;
|
use std::fmt::Debug;
|
||||||
use std::collections::{VecDeque, vec_deque::Drain};
|
use std::collections::{VecDeque, vec_deque::Drain};
|
||||||
use std::collections::CollectionAllocErr::*;
|
use std::collections::TryReserveError::*;
|
||||||
use std::mem::size_of;
|
use std::mem::size_of;
|
||||||
use std::{usize, isize};
|
use std::{usize, isize};
|
||||||
|
|
||||||
|
|
|
@ -70,7 +70,7 @@ use core::ptr::{self, NonNull};
|
||||||
use core::slice::{self, SliceIndex};
|
use core::slice::{self, SliceIndex};
|
||||||
|
|
||||||
use crate::borrow::{ToOwned, Cow};
|
use crate::borrow::{ToOwned, Cow};
|
||||||
use crate::collections::CollectionAllocErr;
|
use crate::collections::TryReserveError;
|
||||||
use crate::boxed::Box;
|
use crate::boxed::Box;
|
||||||
use crate::raw_vec::RawVec;
|
use crate::raw_vec::RawVec;
|
||||||
|
|
||||||
|
@ -498,9 +498,9 @@ impl<T> Vec<T> {
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// #![feature(try_reserve)]
|
/// #![feature(try_reserve)]
|
||||||
/// use std::collections::CollectionAllocErr;
|
/// use std::collections::TryReserveError;
|
||||||
///
|
///
|
||||||
/// fn process_data(data: &[u32]) -> Result<Vec<u32>, CollectionAllocErr> {
|
/// fn process_data(data: &[u32]) -> Result<Vec<u32>, TryReserveError> {
|
||||||
/// let mut output = Vec::new();
|
/// let mut output = Vec::new();
|
||||||
///
|
///
|
||||||
/// // Pre-reserve the memory, exiting if we can't
|
/// // Pre-reserve the memory, exiting if we can't
|
||||||
|
@ -516,7 +516,7 @@ impl<T> Vec<T> {
|
||||||
/// # process_data(&[1, 2, 3]).expect("why is the test harness OOMing on 12 bytes?");
|
/// # process_data(&[1, 2, 3]).expect("why is the test harness OOMing on 12 bytes?");
|
||||||
/// ```
|
/// ```
|
||||||
#[unstable(feature = "try_reserve", reason = "new API", issue="48043")]
|
#[unstable(feature = "try_reserve", reason = "new API", issue="48043")]
|
||||||
pub fn try_reserve(&mut self, additional: usize) -> Result<(), CollectionAllocErr> {
|
pub fn try_reserve(&mut self, additional: usize) -> Result<(), TryReserveError> {
|
||||||
self.buf.try_reserve(self.len, additional)
|
self.buf.try_reserve(self.len, additional)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -538,9 +538,9 @@ impl<T> Vec<T> {
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// #![feature(try_reserve)]
|
/// #![feature(try_reserve)]
|
||||||
/// use std::collections::CollectionAllocErr;
|
/// use std::collections::TryReserveError;
|
||||||
///
|
///
|
||||||
/// fn process_data(data: &[u32]) -> Result<Vec<u32>, CollectionAllocErr> {
|
/// fn process_data(data: &[u32]) -> Result<Vec<u32>, TryReserveError> {
|
||||||
/// let mut output = Vec::new();
|
/// let mut output = Vec::new();
|
||||||
///
|
///
|
||||||
/// // Pre-reserve the memory, exiting if we can't
|
/// // Pre-reserve the memory, exiting if we can't
|
||||||
|
@ -556,7 +556,7 @@ impl<T> Vec<T> {
|
||||||
/// # process_data(&[1, 2, 3]).expect("why is the test harness OOMing on 12 bytes?");
|
/// # process_data(&[1, 2, 3]).expect("why is the test harness OOMing on 12 bytes?");
|
||||||
/// ```
|
/// ```
|
||||||
#[unstable(feature = "try_reserve", reason = "new API", issue="48043")]
|
#[unstable(feature = "try_reserve", reason = "new API", issue="48043")]
|
||||||
pub fn try_reserve_exact(&mut self, additional: usize) -> Result<(), CollectionAllocErr> {
|
pub fn try_reserve_exact(&mut self, additional: usize) -> Result<(), TryReserveError> {
|
||||||
self.buf.try_reserve_exact(self.len, additional)
|
self.buf.try_reserve_exact(self.len, additional)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ use hashbrown::hash_map as base;
|
||||||
|
|
||||||
use crate::borrow::Borrow;
|
use crate::borrow::Borrow;
|
||||||
use crate::cell::Cell;
|
use crate::cell::Cell;
|
||||||
use crate::collections::CollectionAllocErr;
|
use crate::collections::TryReserveError;
|
||||||
use crate::fmt::{self, Debug};
|
use crate::fmt::{self, Debug};
|
||||||
#[allow(deprecated)]
|
#[allow(deprecated)]
|
||||||
use crate::hash::{BuildHasher, Hash, Hasher, SipHasher13};
|
use crate::hash::{BuildHasher, Hash, Hasher, SipHasher13};
|
||||||
|
@ -588,7 +588,7 @@ where
|
||||||
/// ```
|
/// ```
|
||||||
#[inline]
|
#[inline]
|
||||||
#[unstable(feature = "try_reserve", reason = "new API", issue = "48043")]
|
#[unstable(feature = "try_reserve", reason = "new API", issue = "48043")]
|
||||||
pub fn try_reserve(&mut self, additional: usize) -> Result<(), CollectionAllocErr> {
|
pub fn try_reserve(&mut self, additional: usize) -> Result<(), TryReserveError> {
|
||||||
self.base
|
self.base
|
||||||
.try_reserve(additional)
|
.try_reserve(additional)
|
||||||
.map_err(map_collection_alloc_err)
|
.map_err(map_collection_alloc_err)
|
||||||
|
@ -2542,10 +2542,10 @@ fn map_entry<'a, K: 'a, V: 'a>(raw: base::RustcEntry<'a, K, V>) -> Entry<'a, K,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn map_collection_alloc_err(err: hashbrown::CollectionAllocErr) -> CollectionAllocErr {
|
fn map_collection_alloc_err(err: hashbrown::CollectionAllocErr) -> TryReserveError {
|
||||||
match err {
|
match err {
|
||||||
hashbrown::CollectionAllocErr::CapacityOverflow => CollectionAllocErr::CapacityOverflow,
|
hashbrown::CollectionAllocErr::CapacityOverflow => TryReserveError::CapacityOverflow,
|
||||||
hashbrown::CollectionAllocErr::AllocErr => CollectionAllocErr::AllocErr,
|
hashbrown::CollectionAllocErr::AllocErr => TryReserveError::AllocErr,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2605,7 +2605,7 @@ mod test_map {
|
||||||
use super::RandomState;
|
use super::RandomState;
|
||||||
use crate::cell::RefCell;
|
use crate::cell::RefCell;
|
||||||
use rand::{thread_rng, Rng};
|
use rand::{thread_rng, Rng};
|
||||||
use realstd::collections::CollectionAllocErr::*;
|
use realstd::collections::TryReserveError::*;
|
||||||
use realstd::usize;
|
use realstd::usize;
|
||||||
|
|
||||||
// https://github.com/rust-lang/rust/issues/62301
|
// https://github.com/rust-lang/rust/issues/62301
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use crate::borrow::Borrow;
|
use crate::borrow::Borrow;
|
||||||
use crate::collections::CollectionAllocErr;
|
use crate::collections::TryReserveError;
|
||||||
use crate::fmt;
|
use crate::fmt;
|
||||||
use crate::hash::{Hash, BuildHasher};
|
use crate::hash::{Hash, BuildHasher};
|
||||||
use crate::iter::{Chain, FromIterator, FusedIterator};
|
use crate::iter::{Chain, FromIterator, FusedIterator};
|
||||||
|
@ -383,7 +383,7 @@ impl<T, S> HashSet<T, S>
|
||||||
/// ```
|
/// ```
|
||||||
#[inline]
|
#[inline]
|
||||||
#[unstable(feature = "try_reserve", reason = "new API", issue="48043")]
|
#[unstable(feature = "try_reserve", reason = "new API", issue="48043")]
|
||||||
pub fn try_reserve(&mut self, additional: usize) -> Result<(), CollectionAllocErr> {
|
pub fn try_reserve(&mut self, additional: usize) -> Result<(), TryReserveError> {
|
||||||
self.map.try_reserve(additional)
|
self.map.try_reserve(additional)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -427,7 +427,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_crate::collections::CollectionAllocErr;
|
pub use alloc_crate::collections::TryReserveError;
|
||||||
|
|
||||||
mod hash;
|
mod hash;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue