Stabilise 'const_char_encode_utf8';
This commit is contained in:
parent
360f7d7b73
commit
00f9827599
@ -674,8 +674,9 @@ pub const fn len_utf16(self) -> usize {
|
||||
/// 'ß'.encode_utf8(&mut b);
|
||||
/// ```
|
||||
#[stable(feature = "unicode_encode_char", since = "1.15.0")]
|
||||
#[rustc_const_unstable(feature = "const_char_encode_utf8", issue = "130512")]
|
||||
#[rustc_const_stable(feature = "const_char_encode_utf8", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[inline]
|
||||
#[cfg_attr(bootstrap, rustc_allow_const_fn_unstable(const_mut_refs))]
|
||||
pub const fn encode_utf8(self, dst: &mut [u8]) -> &mut str {
|
||||
// SAFETY: `char` is not a surrogate, so this is valid UTF-8.
|
||||
unsafe { from_utf8_unchecked_mut(encode_utf8_raw(self as u32, dst)) }
|
||||
@ -1770,9 +1771,11 @@ const fn len_utf16(code: u32) -> usize {
|
||||
/// Panics if the buffer is not large enough.
|
||||
/// A buffer of length four is large enough to encode any `char`.
|
||||
#[unstable(feature = "char_internals", reason = "exposed only for libstd", issue = "none")]
|
||||
#[rustc_const_unstable(feature = "const_char_encode_utf8", issue = "130512")]
|
||||
#[rustc_const_stable(feature = "const_char_encode_utf8", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[doc(hidden)]
|
||||
#[inline]
|
||||
#[rustc_allow_const_fn_unstable(const_eval_select)]
|
||||
#[cfg_attr(bootstrap, rustc_allow_const_fn_unstable(const_mut_refs))]
|
||||
pub const fn encode_utf8_raw(code: u32, dst: &mut [u8]) -> &mut [u8] {
|
||||
const fn panic_at_const(_code: u32, _len: usize, _dst_len: usize) {
|
||||
// Note that we cannot format in constant expressions.
|
||||
|
@ -119,7 +119,6 @@
|
||||
#![feature(const_bigint_helper_methods)]
|
||||
#![feature(const_black_box)]
|
||||
#![feature(const_char_encode_utf16)]
|
||||
#![feature(const_char_encode_utf8)]
|
||||
#![feature(const_eval_select)]
|
||||
#![feature(const_exact_div)]
|
||||
#![feature(const_float_classify)]
|
||||
|
Loading…
Reference in New Issue
Block a user