1
- #![ cfg_attr( rustfmt, rustfmt_skip) ]
2
-
3
- use core:: mem;
4
1
use core:: cmp:: Ordering ;
5
- use core:: { fmt, char} ;
2
+ use core:: mem;
3
+ use core:: { char, fmt} ;
6
4
#[ cfg( feature = "std" ) ]
7
5
use std:: error:: Error ;
8
6
@@ -332,6 +330,7 @@ impl AsciiChar {
332
330
/// current limitations of `const fn`.
333
331
pub const fn new ( ch : char ) -> AsciiChar {
334
332
use AsciiChar :: * ;
333
+ #[ rustfmt:: skip]
335
334
const ALL : [ AsciiChar ; 128 ] = [
336
335
Null , SOH , SOX , ETX , EOT , ENQ , ACK , Bell ,
337
336
BackSpace , Tab , LineFeed , VT , FF , CarriageReturn , SI , SO ,
@@ -489,7 +488,8 @@ impl AsciiChar {
489
488
#[ inline]
490
489
pub const fn is_ascii_whitespace ( & self ) -> bool {
491
490
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' )
493
493
| ( * self as u8 == 0x0c /*form feed*/ )
494
494
}
495
495
@@ -682,8 +682,8 @@ impl AsciiChar {
682
682
/// Compares two characters case-insensitively.
683
683
#[ inline]
684
684
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 ( ) ) )
687
687
}
688
688
}
689
689
@@ -707,41 +707,42 @@ impl Default for AsciiChar {
707
707
}
708
708
}
709
709
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
+ }
715
717
}
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
+ }
721
723
}
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
+ }
727
729
}
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
+ }
733
735
}
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
+ }
739
741
}
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}
745
746
746
747
/// Error returned by `ToAsciiChar`.
747
748
#[ derive( Clone , Copy , PartialEq , Eq ) ]
@@ -835,7 +836,7 @@ impl ToAsciiChar for u32 {
835
836
unsafe {
836
837
match self {
837
838
0 ..=127 => Ok ( self . to_ascii_char_unchecked ( ) ) ,
838
- _ => Err ( ToAsciiCharError ( ( ) ) )
839
+ _ => Err ( ToAsciiCharError ( ( ) ) ) ,
839
840
}
840
841
}
841
842
}
@@ -903,8 +904,20 @@ mod tests {
903
904
assert_eq ! ( ascii. is_ascii_control( ) , ch. is_ascii_control( ) ) ;
904
905
assert_eq ! ( ascii. is_ascii_graphic( ) , ch. is_ascii_graphic( ) ) ;
905
906
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
+ ) ;
908
921
assert_eq ! ( ascii. is_uppercase( ) , ch. is_uppercase( ) ) ;
909
922
assert_eq ! ( ascii. is_ascii_uppercase( ) , ch. is_ascii_uppercase( ) ) ;
910
923
assert_eq ! ( ascii. is_lowercase( ) , ch. is_lowercase( ) ) ;
@@ -944,7 +957,7 @@ mod tests {
944
957
assert_eq ! ( a. to_ascii_lowercase( ) , a) ;
945
958
assert_eq ! ( a. to_ascii_uppercase( ) , A ) ;
946
959
947
- let mut mutable = ( A , a) ;
960
+ let mut mutable = ( A , a) ;
948
961
mutable. 0 . make_ascii_lowercase ( ) ;
949
962
mutable. 1 . make_ascii_uppercase ( ) ;
950
963
assert_eq ! ( mutable. 0 , a) ;
0 commit comments