Rollup merge of #109598 - veera-sivarajan:improve-wording, r=thomcc

Improve documentation for str::replace() and str::replacen()

Currently, to know what the function will return when the pattern doesn't match, the docs require the reader to understand the implementation detail and mentally evaluate or run the example code. It is not immediately clear.

This PR makes it more explicit so the reader can quickly find the information.
This commit is contained in:
Matthias Krüger 2023-03-31 08:03:14 +02:00 committed by GitHub
commit 41369b734d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -256,7 +256,7 @@ impl str {
/// assert_eq!("than an old", s.replace("is", "an"));
/// ```
///
/// When the pattern doesn't match:
/// When the pattern doesn't match, it returns this string slice as [`String`]:
///
/// ```
/// let s = "this is old";
@ -297,7 +297,7 @@ impl str {
/// assert_eq!("foo foo new23 foo", s.replacen(char::is_numeric, "new", 1));
/// ```
///
/// When the pattern doesn't match:
/// When the pattern doesn't match, it returns this string slice as [`String`]:
///
/// ```
/// let s = "this is old";