Skip to content

Commit 9fe3a39

Browse files
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.
1 parent b72e896 commit 9fe3a39

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

library/alloc/src/str.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ impl str {
256256
/// assert_eq!("than an old", s.replace("is", "an"));
257257
/// ```
258258
///
259-
/// When the pattern doesn't match:
259+
/// When the pattern doesn't match, it returns this string slice as [`String`]:
260260
///
261261
/// ```
262262
/// let s = "this is old";
@@ -297,7 +297,7 @@ impl str {
297297
/// assert_eq!("foo foo new23 foo", s.replacen(char::is_numeric, "new", 1));
298298
/// ```
299299
///
300-
/// When the pattern doesn't match:
300+
/// When the pattern doesn't match, it returns this string slice as [`String`]:
301301
///
302302
/// ```
303303
/// let s = "this is old";

0 commit comments

Comments
 (0)