diff options
| author | The 8472 <git@infinite-source.de> | 2022-10-25 22:55:04 +0200 |
|---|---|---|
| committer | The 8472 <git@infinite-source.de> | 2023-02-28 21:00:01 +0100 |
| commit | a4bdfe24c5f83cbb03febdb9ab5fd22414eac05f (patch) | |
| tree | 7ee8d4a82b299eea7c480b7dbb58511ab6f2fc98 /library/alloc/src | |
| parent | 2b32b315f91536b32ac60ea0d3a93a1feb1d9215 (diff) | |
| download | rust-a4bdfe24c5f83cbb03febdb9ab5fd22414eac05f.tar.gz rust-a4bdfe24c5f83cbb03febdb9ab5fd22414eac05f.zip | |
Support allocators in various Default for IntoIter impls
Global implements Default so we can use that as bound for all allocators
Diffstat (limited to 'library/alloc/src')
| -rw-r--r-- | library/alloc/src/collections/btree/map.rs | 17 | ||||
| -rw-r--r-- | library/alloc/src/collections/btree/set.rs | 5 | ||||
| -rw-r--r-- | library/alloc/src/vec/into_iter.rs | 7 |
3 files changed, 22 insertions, 7 deletions
diff --git a/library/alloc/src/collections/btree/map.rs b/library/alloc/src/collections/btree/map.rs index 8c8a459fec9..61db46314b7 100644 --- a/library/alloc/src/collections/btree/map.rs +++ b/library/alloc/src/collections/btree/map.rs @@ -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`. /// /// ``` diff --git a/library/alloc/src/collections/btree/set.rs b/library/alloc/src/collections/btree/set.rs index 5992b814bba..c2233f86667 100644 --- a/library/alloc/src/collections/btree/set.rs +++ b/library/alloc/src/collections/btree/set.rs @@ -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`. /// /// ``` diff --git a/library/alloc/src/vec/into_iter.rs b/library/alloc/src/vec/into_iter.rs index 8fed4a584a3..f6525eb9003 100644 --- a/library/alloc/src/vec/into_iter.rs +++ b/library/alloc/src/vec/into_iter.rs @@ -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() } } |
