Skip to content

std: note that std::str::from_utf8* functions are aliases to <str>::from_utf8* methods #141112

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 31, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions library/core/src/str/converts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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`].
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should these also be marked deprecated in 2.0, so that uses are warned if someone turned on the deprecated in future lint?

///
/// 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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Loading