Rollup merge of #141112 - xizheyin:issue-141079, r=Mark-Simulacrum
std: note that `std::str::from_utf8*` functions are aliases to `<str>::from_utf8*` methods Closes #141079 r? libs
This commit is contained in:
commit
a2bf37e39e
1 changed files with 8 additions and 0 deletions
|
|
@ -6,6 +6,8 @@ use crate::{mem, ptr};
|
|||
|
||||
/// Converts a slice of bytes to a string slice.
|
||||
///
|
||||
/// This is an alias to [`str::from_utf8`].
|
||||
///
|
||||
/// A string slice ([`&str`]) is made of bytes ([`u8`]), and a byte slice
|
||||
/// ([`&[u8]`][byteslice]) is made of bytes, so this function converts between
|
||||
/// the two. Not all byte slices are valid string slices, however: [`&str`] requires
|
||||
|
|
@ -97,6 +99,8 @@ pub const fn from_utf8(v: &[u8]) -> Result<&str, Utf8Error> {
|
|||
|
||||
/// Converts a mutable slice of bytes to a mutable string slice.
|
||||
///
|
||||
/// This is an alias to [`str::from_utf8_mut`].
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// Basic usage:
|
||||
|
|
@ -142,6 +146,8 @@ pub const fn from_utf8_mut(v: &mut [u8]) -> Result<&mut str, Utf8Error> {
|
|||
/// Converts a slice of bytes to a string slice without checking
|
||||
/// that the string contains valid UTF-8.
|
||||
///
|
||||
/// This is an alias to [`str::from_utf8_unchecked`].
|
||||
///
|
||||
/// See the safe version, [`from_utf8`], for more information.
|
||||
///
|
||||
/// # Safety
|
||||
|
|
@ -178,6 +184,8 @@ pub const unsafe fn from_utf8_unchecked(v: &[u8]) -> &str {
|
|||
/// Converts a slice of bytes to a string slice without checking
|
||||
/// that the string contains valid UTF-8; mutable version.
|
||||
///
|
||||
/// This is an alias to [`str::from_utf8_unchecked_mut`].
|
||||
///
|
||||
/// See the immutable version, [`from_utf8_unchecked()`] for documentation and safety requirements.
|
||||
///
|
||||
/// # Examples
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue