Skip to content

Commit 374e144

Browse files
CoAlloc: VecDeque: tidy
1 parent eb83aba commit 374e144

File tree

3 files changed

+27
-25
lines changed

3 files changed

+27
-25
lines changed

library/alloc/src/collections/vec_deque/into_iter.rs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ where
3838
}
3939

4040
#[stable(feature = "collection_debug", since = "1.17.0")]
41-
impl<T: fmt::Debug, A: Allocator, const COOP_PREFERRED: bool> fmt::Debug for IntoIter<T, A, COOP_PREFERRED>
41+
impl<T: fmt::Debug, A: Allocator, const COOP_PREFERRED: bool> fmt::Debug
42+
for IntoIter<T, A, COOP_PREFERRED>
4243
where
4344
[(); core::alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREFERRED)]:,
4445
{
@@ -67,7 +68,8 @@ where
6768
}
6869

6970
#[stable(feature = "rust1", since = "1.0.0")]
70-
impl<T, A: Allocator, const COOP_PREFERRED: bool> DoubleEndedIterator for IntoIter<T, A, COOP_PREFERRED>
71+
impl<T, A: Allocator, const COOP_PREFERRED: bool> DoubleEndedIterator
72+
for IntoIter<T, A, COOP_PREFERRED>
7173
where
7274
[(); core::alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREFERRED)]:,
7375
{
@@ -78,7 +80,8 @@ where
7880
}
7981

8082
#[stable(feature = "rust1", since = "1.0.0")]
81-
impl<T, A: Allocator, const COOP_PREFERRED: bool> ExactSizeIterator for IntoIter<T, A, COOP_PREFERRED>
83+
impl<T, A: Allocator, const COOP_PREFERRED: bool> ExactSizeIterator
84+
for IntoIter<T, A, COOP_PREFERRED>
8285
where
8386
[(); core::alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREFERRED)]:,
8487
{
@@ -88,14 +91,14 @@ where
8891
}
8992

9093
#[stable(feature = "fused", since = "1.26.0")]
91-
impl<T, A: Allocator, const COOP_PREFERRED: bool> FusedIterator for IntoIter<T, A, COOP_PREFERRED>
92-
where
93-
[(); core::alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREFERRED)]:,
94+
impl<T, A: Allocator, const COOP_PREFERRED: bool> FusedIterator for IntoIter<T, A, COOP_PREFERRED> where
95+
[(); core::alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREFERRED)]:
9496
{
9597
}
9698

9799
#[unstable(feature = "trusted_len", issue = "37572")]
98-
unsafe impl<T, A: Allocator, const COOP_PREFERRED : bool> TrustedLen for IntoIter<T, A, COOP_PREFERRED>
100+
unsafe impl<T, A: Allocator, const COOP_PREFERRED: bool> TrustedLen
101+
for IntoIter<T, A, COOP_PREFERRED>
99102
where
100103
[(); core::alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREFERRED)]:,
101104
{

library/alloc/src/collections/vec_deque/mod.rs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ mod tests;
9797
pub struct VecDeque<
9898
T,
9999
#[unstable(feature = "allocator_api", issue = "32838")] A: Allocator = Global,
100-
const COOP_PREFERRED: bool = {DEFAULT_COOP_PREFERRED!()},
100+
const COOP_PREFERRED: bool = { DEFAULT_COOP_PREFERRED!() },
101101
> where
102102
[(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREFERRED)]:,
103103
{
@@ -570,7 +570,8 @@ where
570570
#[rustc_const_stable(feature = "const_vec_deque_new", since = "CURRENT_RUSTC_VERSION")]
571571
#[must_use]
572572
pub const fn new() -> VecDeque<T, Global, COOP_PREFERRED>
573-
where [(); alloc::co_alloc_metadata_num_slots_with_preference::<Global>(COOP_PREFERRED)]:,
573+
where
574+
[(); alloc::co_alloc_metadata_num_slots_with_preference::<Global>(COOP_PREFERRED)]:,
574575
{
575576
// FIXME: This should just be `VecDeque::new_in(Global)` once that hits stable.
576577
VecDeque { head: 0, len: 0, buf: RawVec::NEW }
@@ -2903,13 +2904,11 @@ where
29032904
}
29042905

29052906
#[stable(feature = "vecdeque_vec_conversions", since = "1.10.0")]
2906-
impl<T, A: Allocator, const COOP_PREFERRED: bool, const OTHER_COOP_PREFERRED: bool> From<Vec<T, A, OTHER_COOP_PREFERRED>>
2907-
for VecDeque<T, A, COOP_PREFERRED>
2907+
impl<T, A: Allocator, const COOP_PREFERRED: bool, const OTHER_COOP_PREFERRED: bool>
2908+
From<Vec<T, A, OTHER_COOP_PREFERRED>> for VecDeque<T, A, COOP_PREFERRED>
29082909
where
29092910
[(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREFERRED)]:,
2910-
[(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(
2911-
OTHER_COOP_PREFERRED,
2912-
)]:,
2911+
[(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(OTHER_COOP_PREFERRED)]:,
29132912
{
29142913
/// Turn a [`Vec<T>`] into a [`VecDeque<T>`].
29152914
///
@@ -2920,16 +2919,19 @@ where
29202919
/// and to not re-allocate the `Vec`'s buffer or allocate
29212920
/// any additional memory.
29222921
#[inline]
2923-
fn from(other: Vec<T, A, OTHER_COOP_PREFERRED>) -> Self
2924-
{
2922+
fn from(other: Vec<T, A, OTHER_COOP_PREFERRED>) -> Self {
29252923
let (ptr, len, cap, alloc) = other.into_raw_parts_with_alloc();
2926-
Self { head: 0, len, buf: unsafe { RawVec::<T, A, COOP_PREFERRED>::from_raw_parts_in(ptr, cap, alloc) } }
2924+
Self {
2925+
head: 0,
2926+
len,
2927+
buf: unsafe { RawVec::<T, A, COOP_PREFERRED>::from_raw_parts_in(ptr, cap, alloc) },
2928+
}
29272929
}
29282930
}
29292931

29302932
#[stable(feature = "vecdeque_vec_conversions", since = "1.10.0")]
2931-
impl<T, A: Allocator, const COOP_PREFERRED: bool, const VECDEQUE_COOP_PREFERRED: bool> From<VecDeque<T, A, VECDEQUE_COOP_PREFERRED>>
2932-
for Vec<T, A, COOP_PREFERRED>
2933+
impl<T, A: Allocator, const COOP_PREFERRED: bool, const VECDEQUE_COOP_PREFERRED: bool>
2934+
From<VecDeque<T, A, VECDEQUE_COOP_PREFERRED>> for Vec<T, A, COOP_PREFERRED>
29332935
where
29342936
[(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREFERRED)]:,
29352937
[(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(VECDEQUE_COOP_PREFERRED)]:,
@@ -2963,11 +2965,9 @@ where
29632965
/// assert_eq!(vec, [8, 9, 1, 2, 3, 4]);
29642966
/// assert_eq!(vec.as_ptr(), ptr);
29652967
/// ```
2966-
fn from(
2967-
mut other: VecDeque<T, A, VECDEQUE_COOP_PREFERRED>,
2968-
) -> Self
2968+
fn from(mut other: VecDeque<T, A, VECDEQUE_COOP_PREFERRED>) -> Self
29692969
where
2970-
[(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(VECDEQUE_COOP_PREFERRED)]:,
2970+
[(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(VECDEQUE_COOP_PREFERRED)]:,
29712971
{
29722972
other.make_contiguous();
29732973

library/alloc/src/collections/vec_deque/spec_from_iter.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ pub(super) trait SpecFromIter<T, I> {
77
fn spec_from_iter(iter: I) -> Self;
88
}
99

10-
impl<T, I, const COOP_PREFERRED: bool> SpecFromIter<T, I>
11-
for VecDeque<T, Global, COOP_PREFERRED>
10+
impl<T, I, const COOP_PREFERRED: bool> SpecFromIter<T, I> for VecDeque<T, Global, COOP_PREFERRED>
1211
where
1312
I: Iterator<Item = T>,
1413
[(); alloc::co_alloc_metadata_num_slots_with_preference::<Global>(COOP_PREFERRED)]:,

0 commit comments

Comments
 (0)