diff options
| author | kennytm <kennytm@gmail.com> | 2018-05-09 17:26:38 +0800 |
|---|---|---|
| committer | kennytm <kennytm@gmail.com> | 2018-05-09 20:29:46 +0800 |
| commit | 4924fea2026c0360cd57106ee6f1199924ad50e1 (patch) | |
| tree | 1a6ea1fe9ae65414a279c97bbd289c141e59ffed /src/liballoc | |
| parent | 4c3ab33f3a94b7ce21a28658d403e27a81ef042d (diff) | |
| parent | a72a0801bdab22d7c0167f67d1148276ea874d2e (diff) | |
Rollup merge of #50511 - Manishearth:must-use, r=QuietMisdreavus
Add some explanations for #[must_use] `#[must_use]` can be given a string argument which is shown whilst warning for things. We should add a string argument to most of the user-exposed ones. I added these for everything but the operators, mostly because I'm not sure what to write there or if we need anything there.
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 |
