diff options
| author | Manish Goregaokar <manishsmail@gmail.com> | 2018-05-07 09:30:11 -0700 |
|---|---|---|
| committer | Manish Goregaokar <manishsmail@gmail.com> | 2018-05-07 10:26:29 -0700 |
| commit | a72a0801bdab22d7c0167f67d1148276ea874d2e (patch) | |
| tree | 7117b694cee859a5646d6b07c07506c4abd102aa /src/liballoc | |
| parent | f8b774fbf1f57e520b58ae3828e4b3a1ddf1d97c (diff) | |
| download | rust-a72a0801bdab22d7c0167f67d1148276ea874d2e.tar.gz rust-a72a0801bdab22d7c0167f67d1148276ea874d2e.zip | |
Add explanation for #[must_use] on string replace methods
Diffstat (limited to 'src/liballoc')
| -rw-r--r-- | src/liballoc/str.rs | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/liballoc/str.rs b/src/liballoc/str.rs index 0cbe65db53c..9e693c89be9 100644 --- a/src/liballoc/str.rs +++ b/src/liballoc/str.rs @@ -207,7 +207,8 @@ impl str { /// let s = "this is old"; /// assert_eq!(s, s.replace("cookie monster", "little lamb")); /// ``` - #[must_use] + #[must_use = "this returns the replaced string as a new allocation, \ + without modifying the original"] #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn replace<'a, P: Pattern<'a>>(&'a self, from: P, to: &str) -> String { @@ -247,7 +248,8 @@ impl str { /// let s = "this is old"; /// assert_eq!(s, s.replacen("cookie monster", "little lamb", 10)); /// ``` - #[must_use] + #[must_use = "this returns the replaced string as a new allocation, \ + without modifying the original"] #[stable(feature = "str_replacen", since = "1.16.0")] pub fn replacen<'a, P: Pattern<'a>>(&'a self, pat: P, to: &str, count: usize) -> String { // Hope to reduce the times of re-allocation |
