str: make as_mut_ptr and as_bytes_mut unstably const · qinheping/verify-rust-std@3a53537 (original) (raw)

`@@ -338,9 +338,10 @@ impl str {

`

338

338

`/// assert_eq!("🍔∈🌏", s);

`

339

339

```` /// ```

````

340

340

`#[stable(feature = "str_mut_extras", since = "1.20.0")]

`

``

341

`+

#[rustc_const_unstable(feature = "const_str_as_mut", issue = "130086")]

`

341

342

`#[must_use]

`

342

343

`#[inline(always)]

`

343

``

`-

pub unsafe fn as_bytes_mut(&mut self) -> &mut [u8] {

`

``

344

`+

pub const unsafe fn as_bytes_mut(&mut self) -> &mut [u8] {

`

344

345

`` // SAFETY: the cast from &str to &[u8] is safe since str

``

345

346

`` // has the same layout as &[u8] (only std can make this guarantee).

``

346

347

`// The pointer dereference is safe since it comes from a mutable reference which

`

`@@ -383,10 +384,11 @@ impl str {

`

383

384

`/// It is your responsibility to make sure that the string slice only gets

`

384

385

`/// modified in a way that it remains valid UTF-8.

`

385

386

`#[stable(feature = "str_as_mut_ptr", since = "1.36.0")]

`

``

387

`+

#[rustc_const_unstable(feature = "const_str_as_mut", issue = "130086")]

`

386

388

`#[rustc_never_returns_null_ptr]

`

387

389

`#[must_use]

`

388

390

`#[inline(always)]

`

389

``

`-

pub fn as_mut_ptr(&mut self) -> *mut u8 {

`

``

391

`+

pub const fn as_mut_ptr(&mut self) -> *mut u8 {

`

390

392

`self as *mut str as *mut u8

`

391

393

`}

`

392

394

``