Skip to content

Removed rustfmt_skip guards from all files. #71

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
Sep 19, 2020
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
95 changes: 54 additions & 41 deletions src/ascii_char.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#![cfg_attr(rustfmt, rustfmt_skip)]

use core::mem;
use core::cmp::Ordering;
use core::{fmt, char};
use core::mem;
use core::{char, fmt};
#[cfg(feature = "std")]
use std::error::Error;

Expand Down Expand Up @@ -332,6 +330,7 @@ impl AsciiChar {
/// current limitations of `const fn`.
pub const fn new(ch: char) -> AsciiChar {
use AsciiChar::*;
#[rustfmt::skip]
const ALL: [AsciiChar; 128] = [
Null, SOH, SOX, ETX, EOT, ENQ, ACK, Bell,
BackSpace, Tab, LineFeed, VT, FF, CarriageReturn, SI, SO,
Expand Down Expand Up @@ -489,7 +488,8 @@ impl AsciiChar {
#[inline]
pub const fn is_ascii_whitespace(&self) -> bool {
self.is_ascii_blank()
| (*self as u8 == b'\n') | (*self as u8 == b'\r')
| (*self as u8 == b'\n')
| (*self as u8 == b'\r')
| (*self as u8 == 0x0c/*form feed*/)
}

Expand Down Expand Up @@ -682,8 +682,8 @@ impl AsciiChar {
/// Compares two characters case-insensitively.
#[inline]
pub const fn eq_ignore_ascii_case(&self, other: &Self) -> bool {
(self.as_byte() == other.as_byte()) |
(self.is_alphabetic() & (self.to_not_upper() == other.to_not_upper()))
(self.as_byte() == other.as_byte())
| (self.is_alphabetic() & (self.to_not_upper() == other.to_not_upper()))
}
}

Expand All @@ -707,41 +707,42 @@ impl Default for AsciiChar {
}
}

macro_rules! impl_into_partial_eq_ord {($wider:ty, $to_wider:expr) => {
impl From<AsciiChar> for $wider {
#[inline]
fn from(a: AsciiChar) -> $wider {
$to_wider(a)
macro_rules! impl_into_partial_eq_ord {
($wider:ty, $to_wider:expr) => {
impl From<AsciiChar> for $wider {
#[inline]
fn from(a: AsciiChar) -> $wider {
$to_wider(a)
}
}
}
impl PartialEq<$wider> for AsciiChar {
#[inline]
fn eq(&self, rhs: &$wider) -> bool {
$to_wider(*self) == *rhs
impl PartialEq<$wider> for AsciiChar {
#[inline]
fn eq(&self, rhs: &$wider) -> bool {
$to_wider(*self) == *rhs
}
}
}
impl PartialEq<AsciiChar> for $wider {
#[inline]
fn eq(&self, rhs: &AsciiChar) -> bool {
*self == $to_wider(*rhs)
impl PartialEq<AsciiChar> for $wider {
#[inline]
fn eq(&self, rhs: &AsciiChar) -> bool {
*self == $to_wider(*rhs)
}
}
}
impl PartialOrd<$wider> for AsciiChar {
#[inline]
fn partial_cmp(&self, rhs: &$wider) -> Option<Ordering> {
$to_wider(*self).partial_cmp(rhs)
impl PartialOrd<$wider> for AsciiChar {
#[inline]
fn partial_cmp(&self, rhs: &$wider) -> Option<Ordering> {
$to_wider(*self).partial_cmp(rhs)
}
}
}
impl PartialOrd<AsciiChar> for $wider {
#[inline]
fn partial_cmp(&self, rhs: &AsciiChar) -> Option<Ordering> {
self.partial_cmp(&$to_wider(*rhs))
impl PartialOrd<AsciiChar> for $wider {
#[inline]
fn partial_cmp(&self, rhs: &AsciiChar) -> Option<Ordering> {
self.partial_cmp(&$to_wider(*rhs))
}
}
}
}}
impl_into_partial_eq_ord!{u8, AsciiChar::as_byte}
impl_into_partial_eq_ord!{char, AsciiChar::as_char}

};
}
impl_into_partial_eq_ord! {u8, AsciiChar::as_byte}
impl_into_partial_eq_ord! {char, AsciiChar::as_char}

/// Error returned by `ToAsciiChar`.
#[derive(Clone, Copy, PartialEq, Eq)]
Expand Down Expand Up @@ -835,7 +836,7 @@ impl ToAsciiChar for u32 {
unsafe {
match self {
0..=127 => Ok(self.to_ascii_char_unchecked()),
_ => Err(ToAsciiCharError(()))
_ => Err(ToAsciiCharError(())),
}
}
}
Expand Down Expand Up @@ -903,8 +904,20 @@ mod tests {
assert_eq!(ascii.is_ascii_control(), ch.is_ascii_control());
assert_eq!(ascii.is_ascii_graphic(), ch.is_ascii_graphic());
assert_eq!(ascii.is_ascii_punctuation(), ch.is_ascii_punctuation());
assert_eq!(ascii.is_whitespace(), ch.is_whitespace(), "{:?} ({:#04x})", ch, byte);
assert_eq!(ascii.is_ascii_whitespace(), ch.is_ascii_whitespace(), "{:?} ({:#04x})", ch, byte);
assert_eq!(
ascii.is_whitespace(),
ch.is_whitespace(),
"{:?} ({:#04x})",
ch,
byte
);
assert_eq!(
ascii.is_ascii_whitespace(),
ch.is_ascii_whitespace(),
"{:?} ({:#04x})",
ch,
byte
);
assert_eq!(ascii.is_uppercase(), ch.is_uppercase());
assert_eq!(ascii.is_ascii_uppercase(), ch.is_ascii_uppercase());
assert_eq!(ascii.is_lowercase(), ch.is_lowercase());
Expand Down Expand Up @@ -944,7 +957,7 @@ mod tests {
assert_eq!(a.to_ascii_lowercase(), a);
assert_eq!(a.to_ascii_uppercase(), A);

let mut mutable = (A,a);
let mut mutable = (A, a);
mutable.0.make_ascii_lowercase();
mutable.1.make_ascii_uppercase();
assert_eq!(mutable.0, a);
Expand Down
Loading