diff options
| author | Veera <sveera.2001@gmail.com> | 2023-03-25 11:41:00 -0400 |
|---|---|---|
| committer | Veera <sveera.2001@gmail.com> | 2023-03-25 11:41:00 -0400 |
| commit | 9fe3a39e3467da1c8a291e7c16f498e3aacfd353 (patch) | |
| tree | a185716cf00208b9d6235354b598fc7f41e2bd03 | |
| parent | b72e896268bd741a2a2bb10028dca9e6f8d0ae63 (diff) | |
| download | rust-9fe3a39e3467da1c8a291e7c16f498e3aacfd353.tar.gz rust-9fe3a39e3467da1c8a291e7c16f498e3aacfd353.zip | |
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.
| -rw-r--r-- | library/alloc/src/str.rs | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/library/alloc/src/str.rs b/library/alloc/src/str.rs index afbe5cfaf8e..b87ef59f64a 100644 --- a/library/alloc/src/str.rs +++ b/library/alloc/src/str.rs @@ -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"; |
