diff options
| author | Matthias Krüger <476013+matthiaskrgr@users.noreply.github.com> | 2025-05-31 18:51:47 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-05-31 18:51:47 +0200 |
| commit | a2bf37e39efa9991467bd2d90804f016f28fa456 (patch) | |
| tree | 87ba7ef58a4c6f820e8030bbc2f12ef9c148bcd5 | |
| parent | 05debb0d0d2ec468e75ffb1bf6b53c702cb819b2 (diff) | |
| parent | 3cba746b4968cf4c17ad0c638ef993dae33b2754 (diff) | |
| download | rust-a2bf37e39efa9991467bd2d90804f016f28fa456.tar.gz rust-a2bf37e39efa9991467bd2d90804f016f28fa456.zip | |
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
| -rw-r--r-- | library/core/src/str/converts.rs | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/library/core/src/str/converts.rs b/library/core/src/str/converts.rs index 058628797ea..6da9dce2d87 100644 --- a/library/core/src/str/converts.rs +++ b/library/core/src/str/converts.rs @@ -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 |
