Skip to content
You signed in with another tab or window. Reload to refresh your session.
You signed out in another tab or window. Reload to refresh your session.
You switched accounts on another tab or window. Reload to refresh your session.
Dismiss alert
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 131
131
#![ feature( const_ipv4) ]
132
132
#![ feature( const_ipv6) ]
133
133
#![ feature( const_likely) ]
134
+ #![ feature( const_make_ascii) ]
134
135
#![ feature( const_maybe_uninit_as_mut_ptr) ]
135
136
#![ feature( const_maybe_uninit_assume_init) ]
136
137
#![ feature( const_nonnull_new) ]
150
151
#![ feature( const_slice_from_raw_parts_mut) ]
151
152
#![ feature( const_slice_from_ref) ]
152
153
#![ feature( const_slice_split_at_mut) ]
154
+ #![ feature( const_str_as_mut) ]
153
155
#![ feature( const_str_from_utf8_unchecked_mut) ]
154
156
#![ feature( const_strict_overflow_ops) ]
155
157
#![ feature( const_swap) ]
Original file line number Diff line number Diff line change @@ -67,10 +67,15 @@ impl [u8] {
67
67
///
68
68
/// [`to_ascii_uppercase`]: #method.to_ascii_uppercase
69
69
#[ stable( feature = "ascii_methods_on_intrinsics" , since = "1.23.0" ) ]
70
+ #[ rustc_const_unstable( feature = "const_make_ascii" , issue = "130698" ) ]
70
71
#[ 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] ;
73
77
byte. make_ascii_uppercase ( ) ;
78
+ i += 0x1 ;
74
79
}
75
80
}
76
81
@@ -84,10 +89,15 @@ impl [u8] {
84
89
///
85
90
/// [`to_ascii_lowercase`]: #method.to_ascii_lowercase
86
91
#[ stable( feature = "ascii_methods_on_intrinsics" , since = "1.23.0" ) ]
92
+ #[ rustc_const_unstable( feature = "const_make_ascii" , issue = "130698" ) ]
87
93
#[ inline]
88
- pub fn make_ascii_lowercase ( & mut self ) {
89
- for byte in self {
94
+ pub const fn make_ascii_
8000
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] ;
90
99
byte. make_ascii_lowercase ( ) ;
100
+ i += 0x1 ;
91
101
}
92
102
}
93
103
Original file line number Diff line number Diff line change @@ -2469,8 +2469,9 @@ impl str {
2469
2469
/// assert_eq!("GRüßE, JüRGEN ❤", s);
2470
2470
/// ```
2471
2471
#[ stable( feature = "ascii_methods_on_intrinsics" , since = "1.23.0" ) ]
2472
+ #[ rustc_const_unstable( feature = "const_make_ascii" , issue = "130698" ) ]
2472
2473
#[ inline]
2473
- pub fn make_ascii_uppercase ( & mut self ) {
2474
+ pub const fn make_ascii_uppercase ( & mut self ) {
2474
2475
// SAFETY: changing ASCII letters only does not invalidate UTF-8.
2475
2476
let me = unsafe { self . as_bytes_mut ( ) } ;
2476
2477
me. make_ascii_uppercase ( )
@@ -2496,8 +2497,9 @@ impl str {
2496
2497
/// assert_eq!("grÜße, jÜrgen ❤", s);
2497
2498
/// ```
2498
2499
#[ stable( feature = "ascii_methods_on_intrinsics" , since = "1.23.0" ) ]
2500
+ #[ rustc_const_unstable( feature = "const_make_ascii" , issue = "130698" ) ]
2499
2501
#[ inline]
2500
- pub fn make_ascii_lowercase ( & mut self ) {
2502
+ pub const fn make_ascii_lowercase ( & mut self ) {
2501
2503
// SAFETY: changing ASCII letters only does not invalidate UTF-8.
2502
2504
let me = unsafe { self . as_bytes_mut ( ) } ;
2503
2505
me. make_ascii_lowercase ( )
You can’t perform that action at this time.
0 commit comments