Skip to content
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

Update/relax str/String utf8 safety docs #134598

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Disambiguate str doc-links
  • Loading branch information
zachs18 committed Dec 21, 2024
commit a29cb96087dabe0ffd6bed517170bf277bac450a
2 changes: 1 addition & 1 deletion library/alloc/src/string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ use crate::vec::Vec;
///
/// # Invariant
///
/// Rust libraries may assume that `String`s are always valid UTF-8, [just like `str`s](str#invariant).
/// Rust libraries may assume that `String`s are always valid UTF-8, [just like `str`s](prim@str#invariant).
///
/// Constructing a non-UTF-8 `String` is not immediate undefined behavior, but any function
/// called on a `String` may assume that it is valid UTF-8, which means that a non-UTF-8 `String`
Expand Down
2 changes: 1 addition & 1 deletion library/core/src/str/converts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ pub const fn from_utf8_mut(v: &mut [u8]) -> Result<&mut str, Utf8Error> {
/// This function is unsafe because it does not check that the bytes passed
/// to it are valid UTF-8. If this constraint is violated, it may cause
/// memory unsafety issues with future users of the `str`, as the rest of
/// the standard library [assumes that `str`s are valid UTF-8](str#invariant).
/// the standard library [assumes that `str`s are valid UTF-8](prim@str#invariant).
///
/// # Examples
///
Expand Down
2 changes: 1 addition & 1 deletion library/core/src/str/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ impl str {
/// bytes which are not valid UTF-8. If this constraint is violated, using
/// the original `str` after the `&mut [u8]` borrow expires may violate memory
/// safety, as the rest of the standard library [assumes that `str`s are
/// valid UTF-8](str#invariant).
/// valid UTF-8](prim@str#invariant).
///
/// # Examples
///
Expand Down
Loading