Skip to content

Add a couple of intra-doc links to str #132398

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 2 commits into from
Nov 2, 2024
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
14 changes: 9 additions & 5 deletions library/core/src/str/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,14 +211,16 @@ impl str {
}
}

/// Finds the closest `x` not exceeding `index` where `is_char_boundary(x)` is `true`.
/// Finds the closest `x` not exceeding `index` where [`is_char_boundary(x)`] is `true`.
///
/// This method can help you truncate a string so that it's still valid UTF-8, but doesn't
/// exceed a given number of bytes. Note that this is done purely at the character level
/// and can still visually split graphemes, even though the underlying characters aren't
/// split. For example, the emoji 🧑‍🔬 (scientist) could be split so that the string only
/// includes 🧑 (person) instead.
///
/// [`is_char_boundary(x)`]: Self::is_char_boundary
///
/// # Examples
///
/// ```
Expand Down Expand Up @@ -247,15 +249,15 @@ impl str {
}
}

/// Finds the closest `x` not below `index` where `is_char_boundary(x)` is `true`.
/// Finds the closest `x` not below `index` where [`is_char_boundary(x)`] is `true`.
///
/// If `index` is greater than the length of the string, this returns the length of the string.
///
/// This method is the natural complement to [`floor_char_boundary`]. See that method
/// for more details.
///
/// [`floor_char_boundary`]: str::floor_char_boundary
///
/// [`is_char_boundary(x)`]: Self::is_char_boundary
///
/// # Examples
///
Expand Down Expand Up @@ -2169,7 +2171,7 @@ impl str {
/// Returns a string slice with the prefix removed.
///
/// If the string starts with the pattern `prefix`, returns the substring after the prefix,
/// wrapped in `Some`. Unlike `trim_start_matches`, this method removes the prefix exactly once.
/// wrapped in `Some`. Unlike [`trim_start_matches`], this method removes the prefix exactly once.
///
/// If the string does not start with `prefix`, returns `None`.
///
Expand All @@ -2178,6 +2180,7 @@ impl str {
///
/// [`char`]: prim@char
/// [pattern]: self::pattern
/// [`trim_start_matches`]: Self::trim_start_matches
///
/// # Examples
///
Expand All @@ -2196,7 +2199,7 @@ impl str {
/// Returns a string slice with the suffix removed.
///
/// If the string ends with the pattern `suffix`, returns the substring before the suffix,
/// wrapped in `Some`. Unlike `trim_end_matches`, this method removes the suffix exactly once.
/// wrapped in `Some`. Unlike [`trim_end_matches`], this method removes the suffix exactly once.
///
/// If the string does not end with `suffix`, returns `None`.
///
Expand All @@ -2205,6 +2208,7 @@ impl str {
///
/// [`char`]: prim@char
/// [pattern]: self::pattern
/// [`trim_end_matches`]: Self::trim_end_matches
///
/// # Examples
///
Expand Down
Loading