Support allocators in various Default for IntoIter impls

Global implements Default so we can use that as bound for all allocators
This commit is contained in:
The 8472 2022-10-25 22:55:04 +02:00
parent 2b32b315f9
commit a4bdfe24c5
3 changed files with 22 additions and 7 deletions

View File

@ -450,7 +450,10 @@ impl<K: Debug, V: Debug, A: Allocator + Clone> Debug for IntoIter<K, V, A> {
}
#[stable(feature = "default_iters", since = "CURRENT_RUSTC_VERSION")]
impl<K, V> Default for IntoIter<K, V> {
impl<K, V, A> Default for IntoIter<K, V, A>
where
A: Allocator + Default + Clone,
{
/// Creates an empty `btree_map::IntoIter`.
///
/// ```
@ -459,7 +462,7 @@ impl<K, V> Default for IntoIter<K, V> {
/// assert_eq!(iter.len(), 0);
/// ```
fn default() -> Self {
IntoIter { range: Default::default(), length: 0, alloc: Global }
IntoIter { range: Default::default(), length: 0, alloc: Default::default() }
}
}
@ -2106,7 +2109,10 @@ impl<K, V, A: Allocator + Clone> ExactSizeIterator for IntoKeys<K, V, A> {
impl<K, V, A: Allocator + Clone> FusedIterator for IntoKeys<K, V, A> {}
#[stable(feature = "default_iters", since = "CURRENT_RUSTC_VERSION")]
impl<K, V> Default for IntoKeys<K, V> {
impl<K, V, A> Default for IntoKeys<K, V, A>
where
A: Allocator + Default + Clone,
{
/// Creates an empty `btree_map::IntoKeys`.
///
/// ```
@ -2154,7 +2160,10 @@ impl<K, V, A: Allocator + Clone> ExactSizeIterator for IntoValues<K, V, A> {
impl<K, V, A: Allocator + Clone> FusedIterator for IntoValues<K, V, A> {}
#[stable(feature = "default_iters", since = "CURRENT_RUSTC_VERSION")]
impl<K, V> Default for IntoValues<K, V> {
impl<K, V, A> Default for IntoValues<K, V, A>
where
A: Allocator + Default + Clone,
{
/// Creates an empty `btree_map::IntoValues`.
///
/// ```

View File

@ -1576,7 +1576,10 @@ impl<T, A: Allocator + Clone> ExactSizeIterator for IntoIter<T, A> {
impl<T, A: Allocator + Clone> FusedIterator for IntoIter<T, A> {}
#[stable(feature = "default_iters", since = "CURRENT_RUSTC_VERSION")]
impl<T> Default for IntoIter<T> {
impl<T, A> Default for IntoIter<T, A>
where
A: Allocator + Default + Clone,
{
/// Creates an empty `btree_set::IntoIter`.
///
/// ```

View File

@ -348,7 +348,10 @@ impl<T, A: Allocator> FusedIterator for IntoIter<T, A> {}
unsafe impl<T, A: Allocator> TrustedLen for IntoIter<T, A> {}
#[stable(feature = "default_iters", since = "CURRENT_RUSTC_VERSION")]
impl<T> Default for IntoIter<T> {
impl<T, A> Default for IntoIter<T, A>
where
A: Allocator + Default,
{
/// Creates an empty `vec::IntoIter`.
///
/// ```
@ -358,7 +361,7 @@ impl<T> Default for IntoIter<T> {
/// assert_eq!(iter.as_slice(), &[]);
/// ```
fn default() -> Self {
super::Vec::new().into_iter()
super::Vec::new_in(Default::default()).into_iter()
}
}