@@ -409,12 +409,12 @@ pub trait OwnedAsciiExt {
409
409
/// Convert the string to ASCII upper case:
410
410
/// ASCII letters 'a' to 'z' are mapped to 'A' to 'Z',
411
411
/// but non-ASCII letters are unchanged.
412
- fn into_ascii_upper ( self ) -> Self ;
412
+ fn into_ascii_uppercase ( self ) -> Self ;
413
413
414
414
/// Convert the string to ASCII lower case:
415
415
/// ASCII letters 'A' to 'Z' are mapped to 'a' to 'z',
416
416
/// but non-ASCII letters are unchanged.
417
- fn into_ascii_lower ( self ) -> Self ;
417
+ fn into_ascii_lowercase ( self ) -> Self ;
418
418
}
419
419
420
420
/// Extension methods for ASCII-subset only operations on string slices
@@ -423,31 +423,31 @@ pub trait AsciiExt<T> for Sized? {
423
423
/// Makes a copy of the string in ASCII upper case:
424
424
/// ASCII letters 'a' to 'z' are mapped to 'A' to 'Z',
425
425
/// but non-ASCII letters are unchanged.
426
- fn to_ascii_upper ( & self ) -> T ;
426
+ fn to_ascii_uppercase ( & self ) -> T ;
427
427
428
428
/// Makes a copy of the string in ASCII lower case:
429
429
/// ASCII letters 'A' to 'Z' are mapped to 'a' to 'z',
430
430
/// but non-ASCII letters are unchanged.
431
- fn to_ascii_lower ( & self ) -> T ;
431
+ fn to_ascii_lowercase ( & self ) -> T ;
432
432
433
433
/// Check that two strings are an ASCII case-insensitive match.
434
- /// Same as `to_ascii_lower (a) == to_ascii_lower(b)`,
434
+ /// Same as `to_ascii_lowercase (a) == to_ascii_lower(b)`,
435
435
/// but without allocating and copying temporary strings.
436
436
fn eq_ignore_ascii_case ( & self , other : & Self ) -> bool ;
437
437
}
438
438
439
439
#[ experimental = "would prefer to do this in a more general way" ]
440
440
impl AsciiExt < String > for str {
441
441
#[ inline]
442
- fn to_ascii_upper ( & self ) -> String {
443
- // Vec<u8>::to_ascii_upper () preserves the UTF-8 invariant.
444
- unsafe { String :: from_utf8_unchecked ( self . as_bytes ( ) . to_ascii_upper ( ) ) }
442
+ fn to_ascii_uppercase ( & self ) -> String {
443
+ // Vec<u8>::to_ascii_uppercase () preserves the UTF-8 invariant.
444
+ unsafe { String :: from_utf8_unchecked ( self . as_bytes ( ) . to_ascii_uppercase ( ) ) }
445
445
}
446
446
447
447
#[ inline]
448
- fn to_ascii_lower ( & self ) -> String {
449
- // Vec<u8>::to_ascii_lower () preserves the UTF-8 invariant.
450
- unsafe { String :: from_utf8_unchecked ( self . as_bytes ( ) . to_ascii_lower ( ) ) }
448
+ fn to_ascii_lowercase ( & self ) -> String {
449
+ // Vec<u8>::to_ascii_lowercase () preserves the UTF-8 invariant.
450
+ unsafe { String :: from_utf8_unchecked ( self . as_bytes ( ) . to_ascii_lowercase ( ) ) }
451
451
}
452
452
453
453
#[ inline]
@@ -459,27 +459,27 @@ impl AsciiExt<String> for str {
459
459
#[ experimental = "would prefer to do this in a more general way" ]
460
460
impl OwnedAsciiExt for String {
461
461
#[ inline]
462
- fn into_ascii_upper ( self ) -> String {
463
- // Vec<u8>::into_ascii_upper () preserves the UTF-8 invariant.
464
- unsafe { String :: from_utf8_unchecked ( self . into_bytes ( ) . into_ascii_upper ( ) ) }
462
+ fn into_ascii_uppercase ( self ) -> String {
463
+ // Vec<u8>::into_ascii_uppercase () preserves the UTF-8 invariant.
464
+ unsafe { String :: from_utf8_unchecked ( self . into_bytes ( ) . into_ascii_uppercase ( ) ) }
465
465
}
466
466
467
467
#[ inline]
468
- fn into_ascii_lower ( self ) -> String {
469
- // Vec<u8>::into_ascii_lower () preserves the UTF-8 invariant.
470
- unsafe { String :: from_utf8_unchecked ( self . into_bytes ( ) . into_ascii_lower ( ) ) }
468
+ fn into_ascii_lowercase ( self ) -> String {
469
+ // Vec<u8>::into_ascii_lowercase () preserves the UTF-8 invariant.
470
+ unsafe { String :: from_utf8_unchecked ( self . into_bytes ( ) . into_ascii_lowercase ( ) ) }
471
471
}
472
472
}
473
473
474
474
#[ experimental = "would prefer to do this in a more general way" ]
475
475
impl AsciiExt < Vec < u8 > > for [ u8 ] {
476
476
#[ inline]
477
- fn to_ascii_upper ( & self ) -> Vec < u8 > {
477
+ fn to_ascii_uppercase ( & self ) -> Vec < u8 > {
478
478
self . iter ( ) . map ( |& byte| ASCII_UPPER_MAP [ byte as uint ] ) . collect ( )
479
479
}
480
480
481
481
#[ inline]
482
- fn to_ascii_lower ( & self ) -> Vec < u8 > {
482
+ fn to_ascii_lowercase ( & self ) -> Vec < u8 > {
483
483
self . iter ( ) . map ( |& byte| ASCII_LOWER_MAP [ byte as uint ] ) . collect ( )
484
484
}
485
485
@@ -497,15 +497,15 @@ impl AsciiExt<Vec<u8>> for [u8] {
497
497
#[ experimental = "would prefer to do this in a more general way" ]
498
498
impl OwnedAsciiExt for Vec < u8 > {
499
499
#[ inline]
500
- fn into_ascii_upper ( mut self ) -> Vec < u8 > {
500
+ fn into_ascii_uppercase ( mut self ) -> Vec < u8 > {
501
501
for byte in self . iter_mut ( ) {
502
502
* byte = ASCII_UPPER_MAP [ * byte as uint ] ;
503
503
}
504
504
self
505
505
}
506
506
507
507
#[ inline]
508
- fn into_ascii_lower ( mut self ) -> Vec < u8 > {
508
+ fn into_ascii_lowercase ( mut self ) -> Vec < u8 > {
509
509
for byte in self . iter_mut ( ) {
510
510
* byte = ASCII_LOWER_MAP [ * byte as uint ] ;
511
511
}
@@ -775,64 +775,64 @@ mod tests {
775
775
}
776
776
777
777
#[ test]
778
- fn test_to_ascii_upper ( ) {
779
- assert_eq ! ( "url()URL()uRl()ürl" . to_ascii_upper ( ) , "URL()URL()URL()üRL" ) ;
780
- assert_eq ! ( "hıKß" . to_ascii_upper ( ) , "HıKß" ) ;
778
+ fn test_to_ascii_uppercase ( ) {
779
+ assert_eq ! ( "url()URL()uRl()ürl" . to_ascii_uppercase ( ) , "URL()URL()URL()üRL" ) ;
780
+ assert_eq ! ( "hıKß" . to_ascii_uppercase ( ) , "HıKß" ) ;
781
781
782
782
let mut i = 0 ;
783
783
while i <= 500 {
784
784
let upper = if 'a' as u32 <= i && i <= 'z' as u32 { i + 'A' as u32 - 'a' as u32 }
785
785
else { i } ;
786
- assert_eq ! ( ( from_u32( i) . unwrap( ) ) . to_string( ) . to_ascii_upper ( ) ,
786
+ assert_eq ! ( ( from_u32( i) . unwrap( ) ) . to_string( ) . to_ascii_uppercase ( ) ,
787
787
( from_u32( upper) . unwrap( ) ) . to_string( ) ) ;
788
788
i += 1 ;
789
789
}
790
790
}
791
791
792
792
#[ test]
793
- fn test_to_ascii_lower ( ) {
794
- assert_eq ! ( "url()URL()uRl()Ürl" . to_ascii_lower ( ) , "url()url()url()Ürl" ) ;
793
+ fn test_to_ascii_lowercase ( ) {
794
+ assert_eq ! ( "url()URL()uRl()Ürl" . to_ascii_lowercase ( ) , "url()url()url()Ürl" ) ;
795
795
// Dotted capital I, Kelvin sign, Sharp S.
796
- assert_eq ! ( "HİKß" . to_ascii_lower ( ) , "hİKß" ) ;
796
+ assert_eq ! ( "HİKß" . to_ascii_lowercase ( ) , "hİKß" ) ;
797
797
798
798
let mut i = 0 ;
799
799
while i <= 500 {
800
800
let lower = if 'A' as u32 <= i && i <= 'Z' as u32 { i + 'a' as u32 - 'A' as u32 }
801
801
else { i } ;
802
- assert_eq ! ( ( from_u32( i) . unwrap( ) ) . to_string( ) . to_ascii_lower ( ) ,
802
+ assert_eq ! ( ( from_u32( i) . unwrap( ) ) . to_string( ) . to_ascii_lowercase ( ) ,
803
803
( from_u32( lower) . unwrap( ) ) . to_string( ) ) ;
804
804
i += 1 ;
805
805
}
806
806
}
807
807
808
808
#[ test]
809
- fn test_into_ascii_upper ( ) {
810
- assert_eq ! ( ( "url()URL()uRl()ürl" . to_string( ) ) . into_ascii_upper ( ) ,
809
+ fn test_into_ascii_uppercase ( ) {
810
+ assert_eq ! ( ( "url()URL()uRl()ürl" . to_string( ) ) . into_ascii_uppercase ( ) ,
811
811
"URL()URL()URL()üRL" . to_string( ) ) ;
812
- assert_eq ! ( ( "hıKß" . to_string( ) ) . into_ascii_upper ( ) , "HıKß" ) ;
812
+ assert_eq ! ( ( "hıKß" . to_string( ) ) . into_ascii_uppercase ( ) , "HıKß" ) ;
813
813
814
814
let mut i = 0 ;
815
815
while i <= 500 {
816
816
let upper = if 'a' as u32 <= i && i <= 'z' as u32 { i + 'A' as u32 - 'a' as u32 }
817
817
else { i } ;
818
- assert_eq ! ( ( from_u32( i) . unwrap( ) ) . to_string( ) . into_ascii_upper ( ) ,
818
+ assert_eq ! ( ( from_u32( i) . unwrap( ) ) . to_string( ) . into_ascii_uppercase ( ) ,
819
819
( from_u32( upper) . unwrap( ) ) . to_string( ) ) ;
820
820
i += 1 ;
821
821
}
822
822
}
823
823
824
824
#[ test]
825
- fn test_into_ascii_lower ( ) {
826
- assert_eq ! ( ( "url()URL()uRl()Ürl" . to_string( ) ) . into_ascii_lower ( ) ,
825
+ fn test_into_ascii_lowercase ( ) {
826
+ assert_eq ! ( ( "url()URL()uRl()Ürl" . to_string( ) ) . into_ascii_lowercase ( ) ,
827
827
"url()url()url()Ürl" ) ;
828
828
// Dotted capital I, Kelvin sign, Sharp S.
829
- assert_eq ! ( ( "HİKß" . to_string( ) ) . into_ascii_lower ( ) , "hİKß" ) ;
829
+ assert_eq ! ( ( "HİKß" . to_string( ) ) . into_ascii_lowercase ( ) , "hİKß" ) ;
830
830
831
831
let mut i = 0 ;
832
832
while i <= 500 {
833
833
let lower = if 'A' as u32 <= i && i <= 'Z' as u32 { i + 'a' as u32 - 'A' as u32 }
834
834
else { i } ;
835
- assert_eq ! ( ( from_u32( i) . unwrap( ) ) . to_string( ) . into_ascii_lower ( ) ,
835
+ assert_eq ! ( ( from_u32( i) . unwrap( ) ) . to_string( ) . into_ascii_lowercase ( ) ,
836
836
( from_u32( lower) . unwrap( ) ) . to_string( ) ) ;
837
837
i += 1 ;
838
838
}
0 commit comments