File tree Expand file tree Collapse file tree 3 files changed +20
-6
lines changed Expand file tree Collapse file tree 3 files changed +20
-6
lines changed Original file line number Diff line number Diff line change 131131#![ feature( const_ipv4) ]
132132#![ feature( const_ipv6) ]
133133#![ feature( const_likely) ]
134+ #![ feature( const_make_ascii) ]
134135#![ feature( const_maybe_uninit_as_mut_ptr) ]
135136#![ feature( const_maybe_uninit_assume_init) ]
136137#![ feature( const_nonnull_new) ]
150151#![ feature( const_slice_from_raw_parts_mut) ]
151152#![ feature( const_slice_from_ref) ]
152153#![ feature( const_slice_split_at_mut) ]
154+ #![ feature( const_str_as_mut) ]
153155#![ feature( const_str_from_utf8_unchecked_mut) ]
154156#![ feature( const_strict_overflow_ops) ]
155157#![ feature( const_swap) ]
Original file line number Diff line number Diff line change @@ -67,10 +67,15 @@ impl [u8] {
6767 ///
6868 /// [`to_ascii_uppercase`]: #method.to_ascii_uppercase
6969 #[ stable( feature = "ascii_methods_on_intrinsics" , since = "1.23.0" ) ]
70+ #[ rustc_const_unstable( feature = "const_make_ascii" , issue = "130698" ) ]
7071 #[ inline]
71- pub fn make_ascii_uppercase ( & mut self ) {
72- for byte in self {
72+ pub const fn make_ascii_uppercase ( & mut self ) {
73+ // FIXME(const-hack): We would like to simply iterate using `for` loops but this isn't currently allowed in constant expressions.
74+ let mut i = 0x0 ;
75+ while i < self . len ( ) {
76+ let byte = & mut self [ i] ;
7377 byte. make_ascii_uppercase ( ) ;
78+ i += 0x1 ;
7479 }
7580 }
7681
@@ -84,10 +89,15 @@ impl [u8] {
8489 ///
8590 /// [`to_ascii_lowercase`]: #method.to_ascii_lowercase
8691 #[ stable( feature = "ascii_methods_on_intrinsics" , since = "1.23.0" ) ]
92+ #[ rustc_const_unstable( feature = "const_make_ascii" , issue = "130698" ) ]
8793 #[ inline]
88- pub fn make_ascii_lowercase ( & mut self ) {
89- for byte in self {
94+ pub const fn make_ascii_lowercase ( & mut self ) {
95+ // FIXME(const-hack): We would like to simply iterate using `for` loops but this isn't currently allowed in constant expressions.
96+ let mut i = 0x0 ;
97+ while i < self . len ( ) {
98+ let byte = & mut self [ i] ;
9099 byte. make_ascii_lowercase ( ) ;
100+ i += 0x1 ;
91101 }
92102 }
93103
Original file line number Diff line number Diff line change @@ -2469,8 +2469,9 @@ impl str {
24692469 /// assert_eq!("GRüßE, JüRGEN ❤", s);
24702470 /// ```
24712471 #[ stable( feature = "ascii_methods_on_intrinsics" , since = "1.23.0" ) ]
2472+ #[ rustc_const_unstable( feature = "const_make_ascii" , issue = "130698" ) ]
24722473 #[ inline]
2473- pub fn make_ascii_uppercase ( & mut self ) {
2474+ pub const fn make_ascii_uppercase ( & mut self ) {
24742475 // SAFETY: changing ASCII letters only does not invalidate UTF-8.
24752476 let me = unsafe { self . as_bytes_mut ( ) } ;
24762477 me. make_ascii_uppercase ( )
@@ -2496,8 +2497,9 @@ impl str {
24962497 /// assert_eq!("grÜße, jÜrgen ❤", s);
24972498 /// ```
24982499 #[ stable( feature = "ascii_methods_on_intrinsics" , since = "1.23.0" ) ]
2500+ #[ rustc_const_unstable( feature = "const_make_ascii" , issue = "130698" ) ]
24992501 #[ inline]
2500- pub fn make_ascii_lowercase ( & mut self ) {
2502+ pub const fn make_ascii_lowercase ( & mut self ) {
25012503 // SAFETY: changing ASCII letters only does not invalidate UTF-8.
25022504 let me = unsafe { self . as_bytes_mut ( ) } ;
25032505 me. make_ascii_lowercase ( )
You can’t perform that action at this time.
0 commit comments