diff options
| author | David Tolnay <dtolnay@gmail.com> | 2019-11-24 01:43:32 -0800 | 
|---|---|---|
| committer | David Tolnay <dtolnay@gmail.com> | 2019-11-26 23:02:11 -0800 | 
| commit | 95e00bfed801e264e9c4ac817004153ca0f19eb6 (patch) | |
| tree | 79549f727c3fc8bb0b09779a7dc3f94df43654f2 /src/libcore/ascii.rs | |
| parent | 809e180a76ce97340bf4354ff357bc59e3ca40b2 (diff) | |
| download | rust-95e00bfed801e264e9c4ac817004153ca0f19eb6.tar.gz rust-95e00bfed801e264e9c4ac817004153ca0f19eb6.zip | |
Format libcore with rustfmt
This commit applies rustfmt with default settings to files in
src/libcore *that are not involved in any currently open PR* to minimize
merge conflicts. The list of files involved in open PRs was determined
by querying GitHub's GraphQL API with this script:
https://gist.github.com/dtolnay/aa9c34993dc051a4f344d1b10e4487e8
With the list of files from the script in `outstanding_files`, the
relevant commands were:
    $ find src/libcore -name '*.rs' | xargs rustfmt --edition=2018
    $ rg libcore outstanding_files | xargs git checkout --
Repeating this process several months apart should get us coverage of
most of the rest of libcore.
Diffstat (limited to 'src/libcore/ascii.rs')
| -rw-r--r-- | src/libcore/ascii.rs | 18 | 
1 files changed, 12 insertions, 6 deletions
| diff --git a/src/libcore/ascii.rs b/src/libcore/ascii.rs index 9b588525bd6..e78dfd1ed4a 100644 --- a/src/libcore/ascii.rs +++ b/src/libcore/ascii.rs @@ -12,8 +12,8 @@ #![stable(feature = "core_ascii", since = "1.26.0")] use crate::fmt; -use crate::ops::Range; use crate::iter::FusedIterator; +use crate::ops::Range; use crate::str::from_utf8_unchecked; /// An iterator over the escaped version of a byte. @@ -100,7 +100,7 @@ pub fn escape_default(c: u8) -> EscapeDefault { b'\\' => ([b'\\', b'\\', 0, 0], 2), b'\'' => ([b'\\', b'\'', 0, 0], 2), b'"' => ([b'\\', b'"', 0, 0], 2), - b'\x20' ..= b'\x7e' => ([c, 0, 0, 0], 1), + b'\x20'..=b'\x7e' => ([c, 0, 0, 0], 1), _ => ([b'\\', b'x', hexify(c >> 4), hexify(c & 0xf)], 4), }; @@ -108,7 +108,7 @@ pub fn escape_default(c: u8) -> EscapeDefault { fn hexify(b: u8) -> u8 { match b { - 0 ..= 9 => b'0' + b, + 0..=9 => b'0' + b, _ => b'a' + b - 10, } } @@ -117,9 +117,15 @@ pub fn escape_default(c: u8) -> EscapeDefault { #[stable(feature = "rust1", since = "1.0.0")] impl Iterator for EscapeDefault { type Item = u8; - fn next(&mut self) -> Option<u8> { self.range.next().map(|i| self.data[i]) } - fn size_hint(&self) -> (usize, Option<usize>) { self.range.size_hint() } - fn last(mut self) -> Option<u8> { self.next_back() } + fn next(&mut self) -> Option<u8> { + self.range.next().map(|i| self.data[i]) + } + fn size_hint(&self) -> (usize, Option<usize>) { + self.range.size_hint() + } + fn last(mut self) -> Option<u8> { + self.next_back() + } } #[stable(feature = "rust1", since = "1.0.0")] impl DoubleEndedIterator for EscapeDefault { | 
