Skip to content

Commit 3508072

Browse files
committed
std: note that std::str::from_utf8* functions are aliases to std::<str>::from_utf8* methods
Signed-off-by: xizheyin <[email protected]>
1 parent a69bc17 commit 3508072

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

library/core/src/str/converts.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use crate::{mem, ptr};
66

77
/// Converts a slice of bytes to a string slice.
88
///
9+
/// This is an alias to [`std::<str>::from_utf8`].
910
/// A string slice ([`&str`]) is made of bytes ([`u8`]), and a byte slice
1011
/// ([`&[u8]`][byteslice]) is made of bytes, so this function converts between
1112
/// the two. Not all byte slices are valid string slices, however: [`&str`] requires
@@ -14,6 +15,7 @@ use crate::{mem, ptr};
1415
///
1516
/// [`&str`]: str
1617
/// [byteslice]: slice
18+
/// [`std::<str>::from_utf8`]: ../../std/primitive.str.html#method.from_utf8
1719
///
1820
/// If you are sure that the byte slice is valid UTF-8, and you don't want to
1921
/// incur the overhead of the validity check, there is an unsafe version of
@@ -97,6 +99,10 @@ pub const fn from_utf8(v: &[u8]) -> Result<&str, Utf8Error> {
9799

98100
/// Converts a mutable slice of bytes to a mutable string slice.
99101
///
102+
/// This is an alias to [`std::<str>::from_utf8_mut`].
103+
///
104+
/// [`std::<str>::from_utf8_mut`]: ../../std/primitive.str.html#method.from_utf8_mut
105+
///
100106
/// # Examples
101107
///
102108
/// Basic usage:
@@ -142,6 +148,10 @@ pub const fn from_utf8_mut(v: &mut [u8]) -> Result<&mut str, Utf8Error> {
142148
/// Converts a slice of bytes to a string slice without checking
143149
/// that the string contains valid UTF-8.
144150
///
151+
/// This is an alias to [`std::<str>::from_utf8_unchecked`].
152+
///
153+
/// [`std::<str>::from_utf8_unchecked`]: ../../std/primitive.str.html#method.from_utf8_unchecked
154+
///
145155
/// See the safe version, [`from_utf8`], for more information.
146156
///
147157
/// # Safety
@@ -178,6 +188,10 @@ pub const unsafe fn from_utf8_unchecked(v: &[u8]) -> &str {
178188
/// Converts a slice of bytes to a string slice without checking
179189
/// that the string contains valid UTF-8; mutable version.
180190
///
191+
/// This is an alias to [`std::<str>::from_utf8_unchecked_mut`].
192+
///
193+
/// [`std::<str>::from_utf8_unchecked_mut`]: ../../std/primitive.str.html#method.from_utf8_unchecked_mut
194+
///
181195
/// See the immutable version, [`from_utf8_unchecked()`] for documentation and safety requirements.
182196
///
183197
/// # Examples

0 commit comments

Comments
 (0)