Skip to content

run rustfmt on libcollections folder #38488

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 21, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/libcollections/binary_heap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ pub struct BinaryHeap<T> {
/// [`peek_mut()`]: struct.BinaryHeap.html#method.peek_mut
#[stable(feature = "binary_heap_peek_mut", since = "1.12.0")]
pub struct PeekMut<'a, T: 'a + Ord> {
heap: &'a mut BinaryHeap<T>
heap: &'a mut BinaryHeap<T>,
}

#[stable(feature = "binary_heap_peek_mut", since = "1.12.0")]
Expand Down Expand Up @@ -385,9 +385,7 @@ impl<T: Ord> BinaryHeap<T> {
if self.is_empty() {
None
} else {
Some(PeekMut {
heap: self
})
Some(PeekMut { heap: self })
}
}

Expand Down Expand Up @@ -1126,7 +1124,9 @@ impl<T: Ord> IntoIterator for BinaryHeap<T> {
}

#[stable(feature = "rust1", since = "1.0.0")]
impl<'a, T> IntoIterator for &'a BinaryHeap<T> where T: Ord {
impl<'a, T> IntoIterator for &'a BinaryHeap<T>
where T: Ord
{
type Item = &'a T;
type IntoIter = Iter<'a, T>;

Expand Down
36 changes: 25 additions & 11 deletions src/libcollections/borrow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ pub trait ToOwned {
}

#[stable(feature = "rust1", since = "1.0.0")]
impl<T> ToOwned for T where T: Clone {
impl<T> ToOwned for T
where T: Clone
{
type Owned = T;
fn to_owned(&self) -> T {
self.clone()
Expand Down Expand Up @@ -117,17 +119,19 @@ pub enum Cow<'a, B: ?Sized + 'a>
{
/// Borrowed data.
#[stable(feature = "rust1", since = "1.0.0")]
Borrowed(#[stable(feature = "rust1", since = "1.0.0")] &'a B),
Borrowed(#[stable(feature = "rust1", since = "1.0.0")]
&'a B),

/// Owned data.
#[stable(feature = "rust1", since = "1.0.0")]
Owned(
#[stable(feature = "rust1", since = "1.0.0")] <B as ToOwned>::Owned
),
Owned(#[stable(feature = "rust1", since = "1.0.0")]
<B as ToOwned>::Owned),
}

#[stable(feature = "rust1", since = "1.0.0")]
impl<'a, B: ?Sized> Clone for Cow<'a, B> where B: ToOwned {
impl<'a, B: ?Sized> Clone for Cow<'a, B>
where B: ToOwned
{
fn clone(&self) -> Cow<'a, B> {
match *self {
Borrowed(b) => Borrowed(b),
Expand All @@ -139,7 +143,9 @@ impl<'a, B: ?Sized> Clone for Cow<'a, B> where B: ToOwned {
}
}

impl<'a, B: ?Sized> Cow<'a, B> where B: ToOwned {
impl<'a, B: ?Sized> Cow<'a, B>
where B: ToOwned
{
/// Acquires a mutable reference to the owned form of the data.
///
/// Clones the data if it is not already owned.
Expand Down Expand Up @@ -194,7 +200,9 @@ impl<'a, B: ?Sized> Cow<'a, B> where B: ToOwned {
}

#[stable(feature = "rust1", since = "1.0.0")]
impl<'a, B: ?Sized> Deref for Cow<'a, B> where B: ToOwned {
impl<'a, B: ?Sized> Deref for Cow<'a, B>
where B: ToOwned
{
type Target = B;

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

#[stable(feature = "rust1", since = "1.0.0")]
impl<'a, B: ?Sized> Ord for Cow<'a, B> where B: Ord + ToOwned {
impl<'a, B: ?Sized> Ord for Cow<'a, B>
where B: Ord + ToOwned
{
#[inline]
fn cmp(&self, other: &Cow<'a, B>) -> Ordering {
Ord::cmp(&**self, &**other)
Expand All @@ -228,7 +238,9 @@ impl<'a, 'b, B: ?Sized, C: ?Sized> PartialEq<Cow<'b, C>> for Cow<'a, B>
}

#[stable(feature = "rust1", since = "1.0.0")]
impl<'a, B: ?Sized> PartialOrd for Cow<'a, B> where B: PartialOrd + ToOwned {
impl<'a, B: ?Sized> PartialOrd for Cow<'a, B>
where B: PartialOrd + ToOwned
{
#[inline]
fn partial_cmp(&self, other: &Cow<'a, B>) -> Option<Ordering> {
PartialOrd::partial_cmp(&**self, &**other)
Expand Down Expand Up @@ -273,7 +285,9 @@ impl<'a, B: ?Sized> Default for Cow<'a, B>
}

#[stable(feature = "rust1", since = "1.0.0")]
impl<'a, B: ?Sized> Hash for Cow<'a, B> where B: Hash + ToOwned {
impl<'a, B: ?Sized> Hash for Cow<'a, B>
where B: Hash + ToOwned
{
#[inline]
fn hash<H: Hasher>(&self, state: &mut H) {
Hash::hash(&**self, state)
Expand Down
3 changes: 2 additions & 1 deletion src/libcollections/enum_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,8 @@ impl<E: CLike> FromIterator<E> for EnumSet<E> {
}
}

impl<'a, E> IntoIterator for &'a EnumSet<E> where E: CLike
impl<'a, E> IntoIterator for &'a EnumSet<E>
where E: CLike
{
type Item = E;
type IntoIter = Iter<E>;
Expand Down
50 changes: 32 additions & 18 deletions src/libcollections/linked_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,15 +225,17 @@ impl<T> LinkedList<T> {
pub fn append(&mut self, other: &mut Self) {
match self.tail {
None => mem::swap(self, other),
Some(tail) => if let Some(other_head) = other.head.take() {
unsafe {
(**tail).next = Some(other_head);
(**other_head).prev = Some(tail);
}
Some(tail) => {
if let Some(other_head) = other.head.take() {
unsafe {
(**tail).next = Some(other_head);
(**other_head).prev = Some(tail);
}

self.tail = other.tail.take();
self.len += mem::replace(&mut other.len, 0);
},
self.tail = other.tail.take();
self.len += mem::replace(&mut other.len, 0);
}
}
}
}

Expand Down Expand Up @@ -674,7 +676,10 @@ impl<T> LinkedList<T> {
reason = "method name and placement protocol are subject to change",
issue = "30172")]
pub fn front_place(&mut self) -> FrontPlace<T> {
FrontPlace { list: self, node: IntermediateBox::make_place() }
FrontPlace {
list: self,
node: IntermediateBox::make_place(),
}
}

/// Returns a place for insertion at the back of the list.
Expand All @@ -699,7 +704,10 @@ impl<T> LinkedList<T> {
reason = "method name and placement protocol are subject to change",
issue = "30172")]
pub fn back_place(&mut self) -> BackPlace<T> {
BackPlace { list: self, node: IntermediateBox::make_place() }
BackPlace {
list: self,
node: IntermediateBox::make_place(),
}
}
}

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

self.list.len += 1;
}
},
}
}

Expand Down Expand Up @@ -1135,9 +1143,15 @@ impl<'a, T> InPlace<T> for BackPlace<'a, T> {
// Ensure that `LinkedList` and its read-only iterators are covariant in their type parameters.
#[allow(dead_code)]
fn assert_covariance() {
fn a<'a>(x: LinkedList<&'static str>) -> LinkedList<&'a str> { x }
fn b<'i, 'a>(x: Iter<'i, &'static str>) -> Iter<'i, &'a str> { x }
fn c<'a>(x: IntoIter<&'static str>) -> IntoIter<&'a str> { x }
fn a<'a>(x: LinkedList<&'static str>) -> LinkedList<&'a str> {
x
}
fn b<'i, 'a>(x: Iter<'i, &'static str>) -> Iter<'i, &'a str> {
x
}
fn c<'a>(x: IntoIter<&'static str>) -> IntoIter<&'a str> {
x
}
}

#[stable(feature = "rust1", since = "1.0.0")]
Expand Down Expand Up @@ -1298,10 +1312,10 @@ mod tests {
fn test_send() {
let n = list_from(&[1, 2, 3]);
thread::spawn(move || {
check_links(&n);
let a: &[_] = &[&1, &2, &3];
assert_eq!(a, &n.iter().collect::<Vec<_>>()[..]);
})
check_links(&n);
let a: &[_] = &[&1, &2, &3];
assert_eq!(a, &n.iter().collect::<Vec<_>>()[..]);
})
.join()
.ok()
.unwrap();
Expand Down
6 changes: 1 addition & 5 deletions src/libcollections/str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1697,11 +1697,7 @@ impl str {
debug_assert!('Σ'.len_utf8() == 2);
let is_word_final = case_ignoreable_then_cased(from[..i].chars().rev()) &&
!case_ignoreable_then_cased(from[i + 2..].chars());
to.push_str(if is_word_final {
"ς"
} else {
"σ"
});
to.push_str(if is_word_final { "ς" } else { "σ" });
}

fn case_ignoreable_then_cased<I: Iterator<Item = char>>(iter: I) -> bool {
Expand Down
10 changes: 3 additions & 7 deletions src/libcollections/string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -542,11 +542,7 @@ impl String {
unsafe { *xs.get_unchecked(i) }
}
fn safe_get(xs: &[u8], i: usize, total: usize) -> u8 {
if i >= total {
0
} else {
unsafe_get(xs, i)
}
if i >= total { 0 } else { unsafe_get(xs, i) }
}

let mut res = String::with_capacity(total);
Expand Down Expand Up @@ -976,7 +972,7 @@ impl String {
pub fn push(&mut self, ch: char) {
match ch.len_utf8() {
1 => self.vec.push(ch as u8),
_ => self.vec.extend_from_slice(ch.encode_utf8(&mut [0;4]).as_bytes()),
_ => self.vec.extend_from_slice(ch.encode_utf8(&mut [0; 4]).as_bytes()),
}
}

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

#[stable(feature = "from_string_for_vec_u8", since = "1.14.0")]
impl From<String> for Vec<u8> {
fn from(string : String) -> Vec<u8> {
fn from(string: String) -> Vec<u8> {
string.into_bytes()
}
}
Expand Down
Loading