@@ -384,8 +384,9 @@ impl char {
384384 /// assert_eq!('❤'.escape_unicode().to_string(), "\\u{2764}");
385385 /// ```
386386 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
387+ #[ rustc_const_stable( feature = "const_char_escape_unicode" , since = "1.50.0" ) ]
387388 #[ inline]
388- pub fn escape_unicode ( self ) -> EscapeUnicode {
389+ pub const fn escape_unicode ( self ) -> EscapeUnicode {
389390 let c = self as u32 ;
390391
391392 // or-ing 1 ensures that for c==0 the code computes that one
@@ -510,8 +511,9 @@ impl char {
510511 /// assert_eq!('"'.escape_default().to_string(), "\\\"");
511512 /// ```
512513 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
514+ #[ rustc_const_stable( feature = "const_char_escape_default" , since = "1.50.0" ) ]
513515 #[ inline]
514- pub fn escape_default ( self ) -> EscapeDefault {
516+ pub const fn escape_default ( self ) -> EscapeDefault {
515517 let init_state = match self {
516518 '\t' => EscapeDefaultState :: Backslash ( 't' ) ,
517519 '\r' => EscapeDefaultState :: Backslash ( 'r' ) ,
@@ -569,8 +571,9 @@ impl char {
569571 /// assert_eq!(len, tokyo.len());
570572 /// ```
571573 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
574+ #[ rustc_const_stable( feature = "const_char_len_utf" , since = "1.50.0" ) ]
572575 #[ inline]
573- pub fn len_utf8 ( self ) -> usize {
576+ pub const fn len_utf8 ( self ) -> usize {
574577 len_utf8 ( self as u32 )
575578 }
576579
@@ -594,8 +597,9 @@ impl char {
594597 /// assert_eq!(len, 2);
595598 /// ```
596599 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
600+ #[ rustc_const_stable( feature = "const_char_len_utf" , since = "1.50.0" ) ]
597601 #[ inline]
598- pub fn len_utf16 ( self ) -> usize {
602+ pub const fn len_utf16 ( self ) -> usize {
599603 let ch = self as u32 ;
600604 if ( ch & 0xFFFF ) == ch { 1 } else { 2 }
601605 }
@@ -1086,8 +1090,9 @@ impl char {
10861090 /// [`make_ascii_uppercase()`]: #method.make_ascii_uppercase
10871091 /// [`to_uppercase()`]: #method.to_uppercase
10881092 #[ stable( feature = "ascii_methods_on_intrinsics" , since = "1.23.0" ) ]
1093+ #[ rustc_const_stable( feature = "const_ascii_methods_on_intrinsics" , since = "1.50.0" ) ]
10891094 #[ inline]
1090- pub fn to_ascii_uppercase ( & self ) -> char {
1095+ pub const fn to_ascii_uppercase ( & self ) -> char {
10911096 if self . is_ascii_lowercase ( ) {
10921097 ( * self as u8 ) . ascii_change_case_unchecked ( ) as char
10931098 } else {
@@ -1118,8 +1123,9 @@ impl char {
11181123 /// [`make_ascii_lowercase()`]: #method.make_ascii_lowercase
11191124 /// [`to_lowercase()`]: #method.to_lowercase
11201125 #[ stable( feature = "ascii_methods_on_intrinsics" , since = "1.23.0" ) ]
1126+ #[ rustc_const_stable( feature = "const_ascii_methods_on_intrinsics" , since = "1.50.0" ) ]
11211127 #[ inline]
1122- pub fn to_ascii_lowercase ( & self ) -> char {
1128+ pub const fn to_ascii_lowercase ( & self ) -> char {
11231129 if self . is_ascii_uppercase ( ) {
11241130 ( * self as u8 ) . ascii_change_case_unchecked ( ) as char
11251131 } else {
@@ -1143,8 +1149,9 @@ impl char {
11431149 /// assert!(!upper_a.eq_ignore_ascii_case(&lower_z));
11441150 /// ```
11451151 #[ stable( feature = "ascii_methods_on_intrinsics" , since = "1.23.0" ) ]
1152+ #[ rustc_const_stable( feature = "const_ascii_methods_on_intrinsics" , since = "1.50.0" ) ]
11461153 #[ inline]
1147- pub fn eq_ignore_ascii_case ( & self , other : & char ) -> bool {
1154+ pub const fn eq_ignore_ascii_case ( & self , other : & char ) -> bool {
11481155 self . to_ascii_lowercase ( ) == other. to_ascii_lowercase ( )
11491156 }
11501157
@@ -1561,7 +1568,7 @@ impl char {
15611568}
15621569
15631570#[ inline]
1564- fn len_utf8 ( code : u32 ) -> usize {
1571+ const fn len_utf8 ( code : u32 ) -> usize {
15651572 if code < MAX_ONE_B {
15661573 1
15671574 } else if code < MAX_TWO_B {
0 commit comments