Skip to content

Commit 5fbf3bf

Browse files
committed
Auto merge of #38488 - srinivasreddy:rf_collections, r=aturon
run rustfmt on libcollections folder
2 parents 1b38776 + 6414e67 commit 5fbf3bf

File tree

7 files changed

+103
-95
lines changed

7 files changed

+103
-95
lines changed

src/libcollections/binary_heap.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ pub struct BinaryHeap<T> {
225225
/// [`peek_mut()`]: struct.BinaryHeap.html#method.peek_mut
226226
#[stable(feature = "binary_heap_peek_mut", since = "1.12.0")]
227227
pub struct PeekMut<'a, T: 'a + Ord> {
228-
heap: &'a mut BinaryHeap<T>
228+
heap: &'a mut BinaryHeap<T>,
229229
}
230230

231231
#[stable(feature = "binary_heap_peek_mut", since = "1.12.0")]
@@ -385,9 +385,7 @@ impl<T: Ord> BinaryHeap<T> {
385385
if self.is_empty() {
386386
None
387387
} else {
388-
Some(PeekMut {
389-
heap: self
390-
})
388+
Some(PeekMut { heap: self })
391389
}
392390
}
393391

@@ -1126,7 +1124,9 @@ impl<T: Ord> IntoIterator for BinaryHeap<T> {
11261124
}
11271125

11281126
#[stable(feature = "rust1", since = "1.0.0")]
1129-
impl<'a, T> IntoIterator for &'a BinaryHeap<T> where T: Ord {
1127+
impl<'a, T> IntoIterator for &'a BinaryHeap<T>
1128+
where T: Ord
1129+
{
11301130
type Item = &'a T;
11311131
type IntoIter = Iter<'a, T>;
11321132

src/libcollections/borrow.rs

+25-11
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,9 @@ pub trait ToOwned {
6363
}
6464

6565
#[stable(feature = "rust1", since = "1.0.0")]
66-
impl<T> ToOwned for T where T: Clone {
66+
impl<T> ToOwned for T
67+
where T: Clone
68+
{
6769
type Owned = T;
6870
fn to_owned(&self) -> T {
6971
self.clone()
@@ -117,17 +119,19 @@ pub enum Cow<'a, B: ?Sized + 'a>
117119
{
118120
/// Borrowed data.
119121
#[stable(feature = "rust1", since = "1.0.0")]
120-
Borrowed(#[stable(feature = "rust1", since = "1.0.0")] &'a B),
122+
Borrowed(#[stable(feature = "rust1", since = "1.0.0")]
123+
&'a B),
121124

122125
/// Owned data.
123126
#[stable(feature = "rust1", since = "1.0.0")]
124-
Owned(
125-
#[stable(feature = "rust1", since = "1.0.0")] <B as ToOwned>::Owned
126-
),
127+
Owned(#[stable(feature = "rust1", since = "1.0.0")]
128+
<B as ToOwned>::Owned),
127129
}
128130

129131
#[stable(feature = "rust1", since = "1.0.0")]
130-
impl<'a, B: ?Sized> Clone for Cow<'a, B> where B: ToOwned {
132+
impl<'a, B: ?Sized> Clone for Cow<'a, B>
133+
where B: ToOwned
134+
{
131135
fn clone(&self) -> Cow<'a, B> {
132136
match *self {
133137
Borrowed(b) => Borrowed(b),
@@ -139,7 +143,9 @@ impl<'a, B: ?Sized> Clone for Cow<'a, B> where B: ToOwned {
139143
}
140144
}
141145

142-
impl<'a, B: ?Sized> Cow<'a, B> where B: ToOwned {
146+
impl<'a, B: ?Sized> Cow<'a, B>
147+
where B: ToOwned
148+
{
143149
/// Acquires a mutable reference to the owned form of the data.
144150
///
145151
/// Clones the data if it is not already owned.
@@ -194,7 +200,9 @@ impl<'a, B: ?Sized> Cow<'a, B> where B: ToOwned {
194200
}
195201

196202
#[stable(feature = "rust1", since = "1.0.0")]
197-
impl<'a, B: ?Sized> Deref for Cow<'a, B> where B: ToOwned {
203+
impl<'a, B: ?Sized> Deref for Cow<'a, B>
204+
where B: ToOwned
205+
{
198206
type Target = B;
199207

200208
fn deref(&self) -> &B {
@@ -209,7 +217,9 @@ impl<'a, B: ?Sized> Deref for Cow<'a, B> where B: ToOwned {
209217
impl<'a, B: ?Sized> Eq for Cow<'a, B> where B: Eq + ToOwned {}
210218

211219
#[stable(feature = "rust1", since = "1.0.0")]
212-
impl<'a, B: ?Sized> Ord for Cow<'a, B> where B: Ord + ToOwned {
220+
impl<'a, B: ?Sized> Ord for Cow<'a, B>
221+
where B: Ord + ToOwned
222+
{
213223
#[inline]
214224
fn cmp(&self, other: &Cow<'a, B>) -> Ordering {
215225
Ord::cmp(&**self, &**other)
@@ -228,7 +238,9 @@ impl<'a, 'b, B: ?Sized, C: ?Sized> PartialEq<Cow<'b, C>> for Cow<'a, B>
228238
}
229239

230240
#[stable(feature = "rust1", since = "1.0.0")]
231-
impl<'a, B: ?Sized> PartialOrd for Cow<'a, B> where B: PartialOrd + ToOwned {
241+
impl<'a, B: ?Sized> PartialOrd for Cow<'a, B>
242+
where B: PartialOrd + ToOwned
243+
{
232244
#[inline]
233245
fn partial_cmp(&self, other: &Cow<'a, B>) -> Option<Ordering> {
234246
PartialOrd::partial_cmp(&**self, &**other)
@@ -273,7 +285,9 @@ impl<'a, B: ?Sized> Default for Cow<'a, B>
273285
}
274286

275287
#[stable(feature = "rust1", since = "1.0.0")]
276-
impl<'a, B: ?Sized> Hash for Cow<'a, B> where B: Hash + ToOwned {
288+
impl<'a, B: ?Sized> Hash for Cow<'a, B>
289+
where B: Hash + ToOwned
290+
{
277291
#[inline]
278292
fn hash<H: Hasher>(&self, state: &mut H) {
279293
Hash::hash(&**self, state)

src/libcollections/enum_set.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,8 @@ impl<E: CLike> FromIterator<E> for EnumSet<E> {
276276
}
277277
}
278278

279-
impl<'a, E> IntoIterator for &'a EnumSet<E> where E: CLike
279+
impl<'a, E> IntoIterator for &'a EnumSet<E>
280+
where E: CLike
280281
{
281282
type Item = E;
282283
type IntoIter = Iter<E>;

src/libcollections/linked_list.rs

+32-18
Original file line numberDiff line numberDiff line change
@@ -225,15 +225,17 @@ impl<T> LinkedList<T> {
225225
pub fn append(&mut self, other: &mut Self) {
226226
match self.tail {
227227
None => mem::swap(self, other),
228-
Some(tail) => if let Some(other_head) = other.head.take() {
229-
unsafe {
230-
(**tail).next = Some(other_head);
231-
(**other_head).prev = Some(tail);
232-
}
228+
Some(tail) => {
229+
if let Some(other_head) = other.head.take() {
230+
unsafe {
231+
(**tail).next = Some(other_head);
232+
(**other_head).prev = Some(tail);
233+
}
233234

234-
self.tail = other.tail.take();
235-
self.len += mem::replace(&mut other.len, 0);
236-
},
235+
self.tail = other.tail.take();
236+
self.len += mem::replace(&mut other.len, 0);
237+
}
238+
}
237239
}
238240
}
239241

@@ -674,7 +676,10 @@ impl<T> LinkedList<T> {
674676
reason = "method name and placement protocol are subject to change",
675677
issue = "30172")]
676678
pub fn front_place(&mut self) -> FrontPlace<T> {
677-
FrontPlace { list: self, node: IntermediateBox::make_place() }
679+
FrontPlace {
680+
list: self,
681+
node: IntermediateBox::make_place(),
682+
}
678683
}
679684

680685
/// Returns a place for insertion at the back of the list.
@@ -699,7 +704,10 @@ impl<T> LinkedList<T> {
699704
reason = "method name and placement protocol are subject to change",
700705
issue = "30172")]
701706
pub fn back_place(&mut self) -> BackPlace<T> {
702-
BackPlace { list: self, node: IntermediateBox::make_place() }
707+
BackPlace {
708+
list: self,
709+
node: IntermediateBox::make_place(),
710+
}
703711
}
704712
}
705713

@@ -852,7 +860,7 @@ impl<'a, T> IterMut<'a, T> {
852860
(**head).prev = node;
853861

854862
self.list.len += 1;
855-
}
863+
},
856864
}
857865
}
858866

@@ -1135,9 +1143,15 @@ impl<'a, T> InPlace<T> for BackPlace<'a, T> {
11351143
// Ensure that `LinkedList` and its read-only iterators are covariant in their type parameters.
11361144
#[allow(dead_code)]
11371145
fn assert_covariance() {
1138-
fn a<'a>(x: LinkedList<&'static str>) -> LinkedList<&'a str> { x }
1139-
fn b<'i, 'a>(x: Iter<'i, &'static str>) -> Iter<'i, &'a str> { x }
1140-
fn c<'a>(x: IntoIter<&'static str>) -> IntoIter<&'a str> { x }
1146+
fn a<'a>(x: LinkedList<&'static str>) -> LinkedList<&'a str> {
1147+
x
1148+
}
1149+
fn b<'i, 'a>(x: Iter<'i, &'static str>) -> Iter<'i, &'a str> {
1150+
x
1151+
}
1152+
fn c<'a>(x: IntoIter<&'static str>) -> IntoIter<&'a str> {
1153+
x
1154+
}
11411155
}
11421156

11431157
#[stable(feature = "rust1", since = "1.0.0")]
@@ -1298,10 +1312,10 @@ mod tests {
12981312
fn test_send() {
12991313
let n = list_from(&[1, 2, 3]);
13001314
thread::spawn(move || {
1301-
check_links(&n);
1302-
let a: &[_] = &[&1, &2, &3];
1303-
assert_eq!(a, &n.iter().collect::<Vec<_>>()[..]);
1304-
})
1315+
check_links(&n);
1316+
let a: &[_] = &[&1, &2, &3];
1317+
assert_eq!(a, &n.iter().collect::<Vec<_>>()[..]);
1318+
})
13051319
.join()
13061320
.ok()
13071321
.unwrap();

src/libcollections/str.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -1697,11 +1697,7 @@ impl str {
16971697
debug_assert!('Σ'.len_utf8() == 2);
16981698
let is_word_final = case_ignoreable_then_cased(from[..i].chars().rev()) &&
16991699
!case_ignoreable_then_cased(from[i + 2..].chars());
1700-
to.push_str(if is_word_final {
1701-
"ς"
1702-
} else {
1703-
"σ"
1704-
});
1700+
to.push_str(if is_word_final { "ς" } else { "σ" });
17051701
}
17061702

17071703
fn case_ignoreable_then_cased<I: Iterator<Item = char>>(iter: I) -> bool {

src/libcollections/string.rs

+3-7
Original file line numberDiff line numberDiff line change
@@ -542,11 +542,7 @@ impl String {
542542
unsafe { *xs.get_unchecked(i) }
543543
}
544544
fn safe_get(xs: &[u8], i: usize, total: usize) -> u8 {
545-
if i >= total {
546-
0
547-
} else {
548-
unsafe_get(xs, i)
549-
}
545+
if i >= total { 0 } else { unsafe_get(xs, i) }
550546
}
551547

552548
let mut res = String::with_capacity(total);
@@ -976,7 +972,7 @@ impl String {
976972
pub fn push(&mut self, ch: char) {
977973
match ch.len_utf8() {
978974
1 => self.vec.push(ch as u8),
979-
_ => self.vec.extend_from_slice(ch.encode_utf8(&mut [0;4]).as_bytes()),
975+
_ => self.vec.extend_from_slice(ch.encode_utf8(&mut [0; 4]).as_bytes()),
980976
}
981977
}
982978

@@ -1935,7 +1931,7 @@ impl<'a> FromIterator<String> for Cow<'a, str> {
19351931

19361932
#[stable(feature = "from_string_for_vec_u8", since = "1.14.0")]
19371933
impl From<String> for Vec<u8> {
1938-
fn from(string : String) -> Vec<u8> {
1934+
fn from(string: String) -> Vec<u8> {
19391935
string.into_bytes()
19401936
}
19411937
}

0 commit comments

Comments
 (0)