Skip to content

Commit 2de8356

Browse files
committed
style: applying Rust style
1 parent 6002b28 commit 2de8356

14 files changed

+74
-80
lines changed

library/alloc/src/vec/cow.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::borrow::Cow;
2-
use core::iter::{FromIterator};
2+
use core::iter::FromIterator;
33

4-
use super::{Vec};
4+
use super::Vec;
55

66
#[stable(feature = "cow_from_vec", since = "1.8.0")]
77
impl<'a, T: Clone> From<&'a [T]> for Cow<'a, [T]> {
@@ -26,10 +26,10 @@ impl<'a, T: Clone> From<&'a Vec<T>> for Cow<'a, [T]> {
2626

2727
#[stable(feature = "rust1", since = "1.0.0")]
2828
impl<'a, T> FromIterator<T> for Cow<'a, [T]>
29-
where
30-
T: Clone,
29+
where
30+
T: Clone,
3131
{
3232
fn from_iter<I: IntoIterator<Item = T>>(it: I) -> Cow<'a, [T]> {
3333
Cow::Owned(FromIterator::from_iter(it))
3434
}
35-
}
35+
}

library/alloc/src/vec/drain.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
use crate::alloc::{Allocator, Global};
2-
use core::iter::{
3-
FusedIterator, TrustedLen,
4-
};
2+
use core::fmt;
3+
use core::iter::{FusedIterator, TrustedLen};
54
use core::mem::{self};
65
use core::ptr::{self, NonNull};
76
use core::slice::{self};
8-
use core::fmt;
97

10-
use super::{Vec};
8+
use super::Vec;
119

1210
/// A draining iterator for `Vec<T>`.
1311
///

library/alloc/src/vec/drain_filter.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1+
use crate::alloc::{Allocator, Global};
12
use core::ptr::{self};
23
use core::slice::{self};
3-
use crate::alloc::{Allocator, Global};
44

5-
use super::{Vec};
5+
use super::Vec;
66

77
/// An iterator which uses a closure to determine if an element should be removed.
88
///
@@ -45,8 +45,8 @@ pub struct DrainFilter<
4545
}
4646

4747
impl<T, F, A: Allocator> DrainFilter<'_, T, F, A>
48-
where
49-
F: FnMut(&mut T) -> bool,
48+
where
49+
F: FnMut(&mut T) -> bool,
5050
{
5151
/// Returns a reference to the underlying allocator.
5252
#[unstable(feature = "allocator_api", issue = "32838")]
@@ -58,8 +58,8 @@ impl<T, F, A: Allocator> DrainFilter<'_, T, F, A>
5858

5959
#[unstable(feature = "drain_filter", reason = "recently added", issue = "43244")]
6060
impl<T, F, A: Allocator> Iterator for DrainFilter<'_, T, F, A>
61-
where
62-
F: FnMut(&mut T) -> bool,
61+
where
62+
F: FnMut(&mut T) -> bool,
6363
{
6464
type Item = T;
6565

@@ -96,20 +96,20 @@ impl<T, F, A: Allocator> Iterator for DrainFilter<'_, T, F, A>
9696

9797
#[unstable(feature = "drain_filter", reason = "recently added", issue = "43244")]
9898
impl<T, F, A: Allocator> Drop for DrainFilter<'_, T, F, A>
99-
where
100-
F: FnMut(&mut T) -> bool,
99+
where
100+
F: FnMut(&mut T) -> bool,
101101
{
102102
fn drop(&mut self) {
103103
struct BackshiftOnDrop<'a, 'b, T, F, A: Allocator>
104-
where
105-
F: FnMut(&mut T) -> bool,
104+
where
105+
F: FnMut(&mut T) -> bool,
106106
{
107107
drain: &'b mut DrainFilter<'a, T, F, A>,
108108
}
109109

110110
impl<'a, 'b, T, F, A: Allocator> Drop for BackshiftOnDrop<'a, 'b, T, F, A>
111-
where
112-
F: FnMut(&mut T) -> bool,
111+
where
112+
F: FnMut(&mut T) -> bool,
113113
{
114114
fn drop(&mut self) {
115115
unsafe {
@@ -140,4 +140,4 @@ impl<T, F, A: Allocator> Drop for DrainFilter<'_, T, F, A>
140140
backshift.drain.for_each(drop);
141141
}
142142
}
143-
}
143+
}

library/alloc/src/vec/in_place_drop.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ use core::slice::{self};
33

44
// A helper struct for in-place iteration that drops the destination slice of iteration,
55
// i.e. the head. The source slice (the tail) is dropped by IntoIter.
6-
pub (super) struct InPlaceDrop<T> {
7-
pub (super) inner: *mut T,
8-
pub (super) dst: *mut T,
6+
pub(super) struct InPlaceDrop<T> {
7+
pub(super) inner: *mut T,
8+
pub(super) dst: *mut T,
99
}
1010

1111
impl<T> InPlaceDrop<T> {

library/alloc/src/vec/into_iter.rs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
use crate::alloc::{Allocator, Global};
22
use crate::raw_vec::RawVec;
3+
use core::fmt;
4+
use core::intrinsics::arith_offset;
5+
use core::iter::{FusedIterator, InPlaceIterable, SourceIter, TrustedLen, TrustedRandomAccess};
36
use core::marker::PhantomData;
4-
use core::intrinsics::{arith_offset};
57
use core::mem::{self};
6-
use core::fmt;
78
use core::ptr::{self, NonNull};
89
use core::slice::{self};
9-
use core::iter::{
10-
FusedIterator, InPlaceIterable, SourceIter, TrustedLen, TrustedRandomAccess,
11-
};
1210

1311
/// An iterator that moves out of a vector.
1412
///
@@ -156,8 +154,8 @@ impl<T, A: Allocator> Iterator for IntoIter<T, A> {
156154
}
157155

158156
unsafe fn __iterator_get_unchecked(&mut self, i: usize) -> Self::Item
159-
where
160-
Self: TrustedRandomAccess,
157+
where
158+
Self: TrustedRandomAccess,
161159
{
162160
// SAFETY: the caller must guarantee that `i` is in bounds of the
163161
// `Vec<T>`, so `i` cannot overflow an `isize`, and the `self.ptr.add(i)`
@@ -211,8 +209,8 @@ unsafe impl<T, A: Allocator> TrustedLen for IntoIter<T, A> {}
211209
// T: Copy as approximation for !Drop since get_unchecked does not advance self.ptr
212210
// and thus we can't implement drop-handling
213211
unsafe impl<T, A: Allocator> TrustedRandomAccess for IntoIter<T, A>
214-
where
215-
T: Copy,
212+
where
213+
T: Copy,
216214
{
217215
fn may_have_side_effect() -> bool {
218216
false

library/alloc/src/vec/is_zero.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,4 +68,4 @@ unsafe impl<T: ?Sized> IsZero for Option<Box<T>> {
6868
fn is_zero(&self) -> bool {
6969
self.is_none()
7070
}
71-
}
71+
}

library/alloc/src/vec/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ use core::convert::TryFrom;
5858
use core::fmt;
5959
use core::hash::{Hash, Hasher};
6060
use core::intrinsics::{arith_offset, assume};
61-
use core::iter::{FromIterator};
61+
use core::iter::FromIterator;
6262
use core::marker::PhantomData;
6363
use core::mem::{self, ManuallyDrop, MaybeUninit};
6464
use core::ops::{self, Index, IndexMut, Range, RangeBounds};
@@ -88,9 +88,9 @@ mod drain;
8888

8989
mod cow;
9090

91+
pub(crate) use self::into_iter::AsIntoIter;
9192
#[stable(feature = "rust1", since = "1.0.0")]
9293
pub use self::into_iter::IntoIter;
93-
pub (crate) use self::into_iter::AsIntoIter;
9494

9595
mod into_iter;
9696

library/alloc/src/vec/partial_eq.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
use crate::alloc::{Allocator};
1+
use crate::alloc::Allocator;
22
use crate::borrow::Cow;
33

4-
use super::{Vec};
4+
use super::Vec;
55

66
macro_rules! __impl_slice_eq1 {
77
([$($vars:tt)*] $lhs:ty, $rhs:ty $(where $ty:ty: $bound:ident)?, #[$stability:meta]) => {

library/alloc/src/vec/source_iter_marker.rs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
use core::iter::{
2-
InPlaceIterable, SourceIter,
3-
};
1+
use core::iter::{InPlaceIterable, SourceIter};
42
use core::mem::{self, ManuallyDrop};
53
use core::ptr::{self};
64

7-
use super::{Vec, InPlaceDrop, AsIntoIter, SpecFromIter, SpecFromIterNested};
5+
use super::{AsIntoIter, InPlaceDrop, SpecFromIter, SpecFromIterNested, Vec};
86

97
/// Specialization marker for collecting an iterator pipeline into a Vec while reusing the
108
/// source allocation, i.e. executing the pipeline in place.
@@ -13,7 +11,7 @@ use super::{Vec, InPlaceDrop, AsIntoIter, SpecFromIter, SpecFromIterNested};
1311
/// which is to be reused. But it is not sufficient for the specialization to be valid. See
1412
/// additional bounds on the impl.
1513
#[rustc_unsafe_specialization_marker]
16-
pub (super) trait SourceIterMarker: SourceIter<Source: AsIntoIter> {}
14+
pub(super) trait SourceIterMarker: SourceIter<Source: AsIntoIter> {}
1715

1816
// The std-internal SourceIter/InPlaceIterable traits are only implemented by chains of
1917
// Adapter<Adapter<Adapter<IntoIter>>> (all owned by core/std). Additional bounds
@@ -24,8 +22,8 @@ pub (super) trait SourceIterMarker: SourceIter<Source: AsIntoIter> {}
2422
impl<T> SourceIterMarker for T where T: SourceIter<Source: AsIntoIter> + InPlaceIterable {}
2523

2624
impl<T, I> SpecFromIter<T, I> for Vec<T>
27-
where
28-
I: Iterator<Item = T> + SourceIterMarker,
25+
where
26+
I: Iterator<Item = T> + SourceIterMarker,
2927
{
3028
default fn from_iter(mut iterator: I) -> Self {
3129
// Additional requirements which cannot expressed via trait bounds. We rely on const eval
@@ -35,9 +33,9 @@ impl<T, I> SpecFromIter<T, I> for Vec<T>
3533
// c) alignments match as required by Alloc contract
3634
if mem::size_of::<T>() == 0
3735
|| mem::size_of::<T>()
38-
!= mem::size_of::<<<I as SourceIter>::Source as AsIntoIter>::Item>()
36+
!= mem::size_of::<<<I as SourceIter>::Source as AsIntoIter>::Item>()
3937
|| mem::align_of::<T>()
40-
!= mem::align_of::<<<I as SourceIter>::Source as AsIntoIter>::Item>()
38+
!= mem::align_of::<<<I as SourceIter>::Source as AsIntoIter>::Item>()
4139
{
4240
// fallback to more generic implementations
4341
return SpecFromIterNested::from_iter(iterator);

library/alloc/src/vec/spec_extend.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
1-
use crate::alloc::{Allocator};
2-
use core::iter::{TrustedLen};
3-
use core::slice::{self};
1+
use crate::alloc::Allocator;
2+
use core::iter::TrustedLen;
43
use core::ptr::{self};
4+
use core::slice::{self};
55

6-
use super::{Vec, IntoIter, SetLenOnDrop};
6+
use super::{IntoIter, SetLenOnDrop, Vec};
77

88
// Specialization trait used for Vec::extend
99
pub(super) trait SpecExtend<T, I> {
1010
fn spec_extend(&mut self, iter: I);
1111
}
1212

1313
impl<T, I, A: Allocator> SpecExtend<T, I> for Vec<T, A>
14-
where
15-
I: Iterator<Item = T>,
14+
where
15+
I: Iterator<Item = T>,
1616
{
1717
default fn spec_extend(&mut self, iter: I) {
1818
self.extend_desugared(iter)
1919
}
2020
}
2121

2222
impl<T, I, A: Allocator> SpecExtend<T, I> for Vec<T, A>
23-
where
24-
I: TrustedLen<Item = T>,
23+
where
24+
I: TrustedLen<Item = T>,
2525
{
2626
default fn spec_extend(&mut self, iterator: I) {
2727
// This is the case for a TrustedLen iterator.
@@ -62,18 +62,18 @@ impl<T, A: Allocator> SpecExtend<T, IntoIter<T>> for Vec<T, A> {
6262
}
6363

6464
impl<'a, T: 'a, I, A: Allocator + 'a> SpecExtend<&'a T, I> for Vec<T, A>
65-
where
66-
I: Iterator<Item = &'a T>,
67-
T: Clone,
65+
where
66+
I: Iterator<Item = &'a T>,
67+
T: Clone,
6868
{
6969
default fn spec_extend(&mut self, iterator: I) {
7070
self.spec_extend(iterator.cloned())
7171
}
7272
}
7373

7474
impl<'a, T: 'a, A: Allocator + 'a> SpecExtend<&'a T, slice::Iter<'a, T>> for Vec<T, A>
75-
where
76-
T: Copy,
75+
where
76+
T: Copy,
7777
{
7878
fn spec_extend(&mut self, iterator: slice::Iter<'a, T>) {
7979
let slice = iterator.as_slice();

library/alloc/src/vec/spec_from_elem.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
use crate::alloc::{Allocator};
1+
use crate::alloc::Allocator;
22
use crate::raw_vec::RawVec;
33
use core::ptr::{self};
44

5-
use super::{Vec, IsZero, ExtendElement};
5+
use super::{ExtendElement, IsZero, Vec};
66

77
// Specialization trait used for Vec::from_elem
88
pub(super) trait SpecFromElem: Sized {
@@ -57,4 +57,4 @@ impl<T: Clone + IsZero> SpecFromElem for T {
5757
v.extend_with(n, ExtendElement(elem));
5858
v
5959
}
60-
}
60+
}

library/alloc/src/vec/spec_from_iter.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
use crate::alloc::Global;
2-
use core::mem::{ManuallyDrop};
2+
use core::mem::ManuallyDrop;
33
use core::ptr::{self};
44
use core::slice::{self};
55

6-
use super::{Vec, IntoIter, SpecFromIterNested, SpecExtend};
6+
use super::{IntoIter, SpecExtend, SpecFromIterNested, Vec};
77

88
/// Specialization trait used for Vec::from_iter
99
///
@@ -30,8 +30,8 @@ pub(super) trait SpecFromIter<T, I> {
3030
}
3131

3232
impl<T, I> SpecFromIter<T, I> for Vec<T>
33-
where
34-
I: Iterator<Item = T>,
33+
where
34+
I: Iterator<Item = T>,
3535
{
3636
default fn from_iter(iterator: I) -> Self {
3737
SpecFromIterNested::from_iter(iterator)
@@ -68,9 +68,9 @@ impl<T> SpecFromIter<T, IntoIter<T>> for Vec<T> {
6868
}
6969

7070
impl<'a, T: 'a, I> SpecFromIter<&'a T, I> for Vec<T>
71-
where
72-
I: Iterator<Item = &'a T>,
73-
T: Clone,
71+
where
72+
I: Iterator<Item = &'a T>,
73+
T: Clone,
7474
{
7575
default fn from_iter(iterator: I) -> Self {
7676
SpecFromIter::from_iter(iterator.cloned())

library/alloc/src/vec/spec_from_iter_nested.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1+
use core::iter::TrustedLen;
12
use core::ptr::{self};
2-
use core::iter::{TrustedLen};
33

4-
use super::{Vec, SpecExtend};
4+
use super::{SpecExtend, Vec};
55

66
/// Another specialization trait for Vec::from_iter
77
/// necessary to manually prioritize overlapping specializations
@@ -11,8 +11,8 @@ pub(super) trait SpecFromIterNested<T, I> {
1111
}
1212

1313
impl<T, I> SpecFromIterNested<T, I> for Vec<T>
14-
where
15-
I: Iterator<Item = T>,
14+
where
15+
I: Iterator<Item = T>,
1616
{
1717
default fn from_iter(mut iterator: I) -> Self {
1818
// Unroll the first iteration, as the vector is going to be
@@ -40,8 +40,8 @@ impl<T, I> SpecFromIterNested<T, I> for Vec<T>
4040
}
4141

4242
impl<T, I> SpecFromIterNested<T, I> for Vec<T>
43-
where
44-
I: TrustedLen<Item = T>,
43+
where
44+
I: TrustedLen<Item = T>,
4545
{
4646
fn from_iter(iterator: I) -> Self {
4747
let mut vector = match iterator.size_hint() {

0 commit comments

Comments
 (0)