about summary refs log tree commit diff
path: root/src/liballoc/str.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2019-12-23 02:47:52 +0000
committerbors <bors@rust-lang.org>2019-12-23 02:47:52 +0000
commita916ac22b9f7f1f0f7aba0a41a789b3ecd765018 (patch)
tree139cba4184f0f290fdbdff1aa0aa68352b16ccbb /src/liballoc/str.rs
parent9b98af84c4aa66392236fff59c86da2130d46d46 (diff)
parent0f24ccd21d9f734a21daaf3566900127167556d1 (diff)
Auto merge of #67540 - Mark-Simulacrum:fmt-the-world, r=Centril
Format the world

This PR modifies the formatting infrastructure a bit in the first commit (to enable the forgotten 2018 edition), as well as removes most directories from the ignore list in rustfmt.toml. It then follows that up with the second commit which runs `x.py fmt` and formats the entire repository.

We continue to not format the test directory (`src/test`) because of interactions with pretty printing and, in part, because re-blessing all of those files is somewhat harder to review, so is best suited for a follow up PR in my opinion.
Diffstat (limited to 'src/liballoc/str.rs')
-rw-r--r--src/liballoc/str.rs64
1 files changed, 31 insertions, 33 deletions
diff --git a/src/liballoc/str.rs b/src/liballoc/str.rs
index 83816d8b954..843a2f1f8e9 100644
--- a/src/liballoc/str.rs
+++ b/src/liballoc/str.rs
@@ -23,16 +23,15 @@
 //! ```
 
 #![stable(feature = "rust1", since = "1.0.0")]
-
 // Many of the usings in this module are only used in the test configuration.
 // It's cleaner to just turn off the unused_imports warning than to fix them.
 #![allow(unused_imports)]
 
 use core::borrow::{Borrow, BorrowMut};
-use core::str::pattern::{Pattern, Searcher, ReverseSearcher, DoubleEndedSearcher};
+use core::iter::FusedIterator;
 use core::mem;
 use core::ptr;
-use core::iter::FusedIterator;
+use core::str::pattern::{DoubleEndedSearcher, Pattern, ReverseSearcher, Searcher};
 use core::unicode::conversions;
 
 use crate::borrow::ToOwned;
@@ -42,34 +41,34 @@ use crate::string::String;
 use crate::vec::Vec;
 
 #[stable(feature = "rust1", since = "1.0.0")]
-pub use core::str::{FromStr, Utf8Error};
-#[allow(deprecated)]
+pub use core::str::pattern;
+#[stable(feature = "encode_utf16", since = "1.8.0")]
+pub use core::str::EncodeUtf16;
+#[stable(feature = "split_ascii_whitespace", since = "1.34.0")]
+pub use core::str::SplitAsciiWhitespace;
 #[stable(feature = "rust1", since = "1.0.0")]
-pub use core::str::{Lines, LinesAny};
+pub use core::str::SplitWhitespace;
 #[stable(feature = "rust1", since = "1.0.0")]
-pub use core::str::{Split, RSplit};
+pub use core::str::{from_utf8, from_utf8_mut, Bytes, CharIndices, Chars};
 #[stable(feature = "rust1", since = "1.0.0")]
-pub use core::str::{SplitN, RSplitN};
+pub use core::str::{from_utf8_unchecked, from_utf8_unchecked_mut, ParseBoolError};
+#[stable(feature = "str_escape", since = "1.34.0")]
+pub use core::str::{EscapeDebug, EscapeDefault, EscapeUnicode};
 #[stable(feature = "rust1", since = "1.0.0")]
-pub use core::str::{SplitTerminator, RSplitTerminator};
+pub use core::str::{FromStr, Utf8Error};
+#[allow(deprecated)]
 #[stable(feature = "rust1", since = "1.0.0")]
-pub use core::str::{Matches, RMatches};
+pub use core::str::{Lines, LinesAny};
 #[stable(feature = "rust1", since = "1.0.0")]
 pub use core::str::{MatchIndices, RMatchIndices};
 #[stable(feature = "rust1", since = "1.0.0")]
-pub use core::str::{from_utf8, from_utf8_mut, Chars, CharIndices, Bytes};
+pub use core::str::{Matches, RMatches};
 #[stable(feature = "rust1", since = "1.0.0")]
-pub use core::str::{from_utf8_unchecked, from_utf8_unchecked_mut, ParseBoolError};
+pub use core::str::{RSplit, Split};
 #[stable(feature = "rust1", since = "1.0.0")]
-pub use core::str::SplitWhitespace;
+pub use core::str::{RSplitN, SplitN};
 #[stable(feature = "rust1", since = "1.0.0")]
-pub use core::str::pattern;
-#[stable(feature = "encode_utf16", since = "1.8.0")]
-pub use core::str::EncodeUtf16;
-#[stable(feature = "split_ascii_whitespace", since = "1.34.0")]
-pub use core::str::SplitAsciiWhitespace;
-#[stable(feature = "str_escape", since = "1.34.0")]
-pub use core::str::{EscapeDebug, EscapeDefault, EscapeUnicode};
+pub use core::str::{RSplitTerminator, SplitTerminator};
 
 /// Note: `str` in `Concat<str>` is not meaningful here.
 /// This type parameter of the trait only exists to enable another impl.
@@ -87,9 +86,7 @@ impl<S: Borrow<str>> Join<&str> for [S] {
     type Output = String;
 
     fn join(slice: &Self, sep: &str) -> String {
-        unsafe {
-            String::from_utf8_unchecked( join_generic_copy(slice, sep.as_bytes()) )
-        }
+        unsafe { String::from_utf8_unchecked(join_generic_copy(slice, sep.as_bytes())) }
     }
 }
 
@@ -123,10 +120,10 @@ macro_rules! spezialize_for_lengths {
 macro_rules! copy_slice_and_advance {
     ($target:expr, $bytes:expr) => {
         let len = $bytes.len();
-        let (head, tail) = {$target}.split_at_mut(len);
+        let (head, tail) = { $target }.split_at_mut(len);
         head.copy_from_slice($bytes);
         $target = tail;
-    }
+    };
 }
 
 // Optimized join implementation that works for both Vec<T> (T: Copy) and String's inner vec
@@ -156,11 +153,12 @@ where
     // if the `len` calculation overflows, we'll panic
     // we would have run out of memory anyway and the rest of the function requires
     // the entire Vec pre-allocated for safety
-    let len =  sep_len.checked_mul(iter.len()).and_then(|n| {
-            slice.iter()
-                .map(|s| s.borrow().as_ref().len())
-                .try_fold(n, usize::checked_add)
-        }).expect("attempt to join into collection with len > usize::MAX");
+    let len = sep_len
+        .checked_mul(iter.len())
+        .and_then(|n| {
+            slice.iter().map(|s| s.borrow().as_ref().len()).try_fold(n, usize::checked_add)
+        })
+        .expect("attempt to join into collection with len > usize::MAX");
 
     // crucial for safety
     let mut result = Vec::with_capacity(len);
@@ -390,13 +388,13 @@ impl str {
             // See http://www.unicode.org/versions/Unicode7.0.0/ch03.pdf#G33992
             // for the definition of `Final_Sigma`.
             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());
+            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 { "σ" });
         }
 
         fn case_ignoreable_then_cased<I: Iterator<Item = char>>(iter: I) -> bool {
-            use core::unicode::derived_property::{Cased, Case_Ignorable};
+            use core::unicode::derived_property::{Case_Ignorable, Cased};
             match iter.skip_while(|&c| Case_Ignorable(c)).next() {
                 Some(c) => Cased(c),
                 None => false,