1- #![ cfg_attr( rustfmt, rustfmt_skip) ]
2-
3- use core:: mem;
41use core:: cmp:: Ordering ;
5- use core:: { fmt, char} ;
2+ use core:: mem;
3+ use core:: { char, fmt} ;
64#[ cfg( feature = "std" ) ]
75use std:: error:: Error ;
86
@@ -332,6 +330,7 @@ impl AsciiChar {
332330 /// current limitations of `const fn`.
333331 pub const fn new ( ch : char ) -> AsciiChar {
334332 use AsciiChar :: * ;
333+ #[ rustfmt:: skip]
335334 const ALL : [ AsciiChar ; 128 ] = [
336335 Null , SOH , SOX , ETX , EOT , ENQ , ACK , Bell ,
337336 BackSpace , Tab , LineFeed , VT , FF , CarriageReturn , SI , SO ,
@@ -489,7 +488,8 @@ impl AsciiChar {
489488 #[ inline]
490489 pub const fn is_ascii_whitespace ( & self ) -> bool {
491490 self . is_ascii_blank ( )
492- | ( * self as u8 == b'\n' ) | ( * self as u8 == b'\r' )
491+ | ( * self as u8 == b'\n' )
492+ | ( * self as u8 == b'\r' )
493493 | ( * self as u8 == 0x0c /*form feed*/ )
494494 }
495495
@@ -682,8 +682,8 @@ impl AsciiChar {
682682 /// Compares two characters case-insensitively.
683683 #[ inline]
684684 pub const fn eq_ignore_ascii_case ( & self , other : & Self ) -> bool {
685- ( self . as_byte ( ) == other. as_byte ( ) ) |
686- ( self . is_alphabetic ( ) & ( self . to_not_upper ( ) == other. to_not_upper ( ) ) )
685+ ( self . as_byte ( ) == other. as_byte ( ) )
686+ | ( self . is_alphabetic ( ) & ( self . to_not_upper ( ) == other. to_not_upper ( ) ) )
687687 }
688688}
689689
@@ -707,41 +707,42 @@ impl Default for AsciiChar {
707707 }
708708}
709709
710- macro_rules! impl_into_partial_eq_ord { ( $wider: ty, $to_wider: expr) => {
711- impl From <AsciiChar > for $wider {
712- #[ inline]
713- fn from( a: AsciiChar ) -> $wider {
714- $to_wider( a)
710+ macro_rules! impl_into_partial_eq_ord {
711+ ( $wider: ty, $to_wider: expr) => {
712+ impl From <AsciiChar > for $wider {
713+ #[ inline]
714+ fn from( a: AsciiChar ) -> $wider {
715+ $to_wider( a)
716+ }
715717 }
716- }
717- impl PartialEq <$wider> for AsciiChar {
718- # [ inline ]
719- fn eq ( & self , rhs : & $wider ) -> bool {
720- $to_wider ( * self ) == * rhs
718+ impl PartialEq <$wider> for AsciiChar {
719+ # [ inline ]
720+ fn eq ( & self , rhs : & $wider ) -> bool {
721+ $to_wider ( * self ) == * rhs
722+ }
721723 }
722- }
723- impl PartialEq < AsciiChar > for $wider {
724- # [ inline ]
725- fn eq ( & self , rhs : & AsciiChar ) -> bool {
726- * self == $to_wider ( * rhs )
724+ impl PartialEq < AsciiChar > for $wider {
725+ # [ inline ]
726+ fn eq ( & self , rhs : & AsciiChar ) -> bool {
727+ * self == $to_wider ( * rhs )
728+ }
727729 }
728- }
729- impl PartialOrd <$wider> for AsciiChar {
730- # [ inline ]
731- fn partial_cmp ( & self , rhs : & $wider ) -> Option < Ordering > {
732- $to_wider ( * self ) . partial_cmp ( rhs )
730+ impl PartialOrd <$wider> for AsciiChar {
731+ # [ inline ]
732+ fn partial_cmp ( & self , rhs : & $wider ) -> Option < Ordering > {
733+ $to_wider ( * self ) . partial_cmp ( rhs )
734+ }
733735 }
734- }
735- impl PartialOrd < AsciiChar > for $wider {
736- # [ inline ]
737- fn partial_cmp ( & self , rhs : & AsciiChar ) -> Option < Ordering > {
738- self . partial_cmp ( & $to_wider ( * rhs ) )
736+ impl PartialOrd < AsciiChar > for $wider {
737+ # [ inline ]
738+ fn partial_cmp ( & self , rhs : & AsciiChar ) -> Option < Ordering > {
739+ self . partial_cmp ( & $to_wider ( * rhs ) )
740+ }
739741 }
740- }
741- } }
742- impl_into_partial_eq_ord ! { u8 , AsciiChar :: as_byte}
743- impl_into_partial_eq_ord ! { char , AsciiChar :: as_char}
744-
742+ } ;
743+ }
744+ impl_into_partial_eq_ord ! { u8 , AsciiChar :: as_byte}
745+ impl_into_partial_eq_ord ! { char , AsciiChar :: as_char}
745746
746747/// Error returned by `ToAsciiChar`.
747748#[ derive( Clone , Copy , PartialEq , Eq ) ]
@@ -835,7 +836,7 @@ impl ToAsciiChar for u32 {
835836 unsafe {
836837 match self {
837838 0 ..=127 => Ok ( self . to_ascii_char_unchecked ( ) ) ,
838- _ => Err ( ToAsciiCharError ( ( ) ) )
839+ _ => Err ( ToAsciiCharError ( ( ) ) ) ,
839840 }
840841 }
841842 }
@@ -903,8 +904,20 @@ mod tests {
903904 assert_eq ! ( ascii. is_ascii_control( ) , ch. is_ascii_control( ) ) ;
904905 assert_eq ! ( ascii. is_ascii_graphic( ) , ch. is_ascii_graphic( ) ) ;
905906 assert_eq ! ( ascii. is_ascii_punctuation( ) , ch. is_ascii_punctuation( ) ) ;
906- assert_eq ! ( ascii. is_whitespace( ) , ch. is_whitespace( ) , "{:?} ({:#04x})" , ch, byte) ;
907- assert_eq ! ( ascii. is_ascii_whitespace( ) , ch. is_ascii_whitespace( ) , "{:?} ({:#04x})" , ch, byte) ;
907+ assert_eq ! (
908+ ascii. is_whitespace( ) ,
909+ ch. is_whitespace( ) ,
910+ "{:?} ({:#04x})" ,
911+ ch,
912+ byte
913+ ) ;
914+ assert_eq ! (
915+ ascii. is_ascii_whitespace( ) ,
916+ ch. is_ascii_whitespace( ) ,
917+ "{:?} ({:#04x})" ,
918+ ch,
919+ byte
920+ ) ;
908921 assert_eq ! ( ascii. is_uppercase( ) , ch. is_uppercase( ) ) ;
909922 assert_eq ! ( ascii. is_ascii_uppercase( ) , ch. is_ascii_uppercase( ) ) ;
910923 assert_eq ! ( ascii. is_lowercase( ) , ch. is_lowercase( ) ) ;
@@ -944,7 +957,7 @@ mod tests {
944957 assert_eq ! ( a. to_ascii_lowercase( ) , a) ;
945958 assert_eq ! ( a. to_ascii_uppercase( ) , A ) ;
946959
947- let mut mutable = ( A , a) ;
960+ let mut mutable = ( A , a) ;
948961 mutable. 0 . make_ascii_lowercase ( ) ;
949962 mutable. 1 . make_ascii_uppercase ( ) ;
950963 assert_eq ! ( mutable. 0 , a) ;
0 commit comments