about summary refs log tree commit diff
path: root/src/liballoc
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume1.gomez@gmail.com>2018-04-26 10:11:11 +0200
committerGitHub <noreply@github.com>2018-04-26 10:11:11 +0200
commit3b49b27e0cb07c8735b534c3825b491a585ab404 (patch)
treeec776ae3163d4edba459366a2c474d952dba7739 /src/liballoc
parentc18778704c691c172274b23ee80927714ac2acc4 (diff)
parent5d37ba1990bdc552694383d2a3c6cbeb72b77f49 (diff)
downloadrust-3b49b27e0cb07c8735b534c3825b491a585ab404.tar.gz
rust-3b49b27e0cb07c8735b534c3825b491a585ab404.zip
Rollup merge of #50177 - matthiaskrgr:std_std_replacen__must_use, r=oli-obk
mark std::str::replace(,n) as #[must_use]

let x = "a b c c";
x.replacen("c", "d", 2");
might not do what people might think it does.
Diffstat (limited to 'src/liballoc')
-rw-r--r--src/liballoc/lib.rs1
-rw-r--r--src/liballoc/str.rs2
2 files changed, 3 insertions, 0 deletions
diff --git a/src/liballoc/lib.rs b/src/liballoc/lib.rs
index 6399be98cd5..021395d0c82 100644
--- a/src/liballoc/lib.rs
+++ b/src/liballoc/lib.rs
@@ -96,6 +96,7 @@
 #![feature(dropck_eyepatch)]
 #![feature(exact_size_is_empty)]
 #![feature(fmt_internals)]
+#![feature(fn_must_use)]
 #![feature(from_ref)]
 #![feature(fundamental)]
 #![feature(lang_items)]
diff --git a/src/liballoc/str.rs b/src/liballoc/str.rs
index cac94edf649..0cbe65db53c 100644
--- a/src/liballoc/str.rs
+++ b/src/liballoc/str.rs
@@ -207,6 +207,7 @@ impl str {
     /// let s = "this is old";
     /// assert_eq!(s, s.replace("cookie monster", "little lamb"));
     /// ```
+    #[must_use]
     #[stable(feature = "rust1", since = "1.0.0")]
     #[inline]
     pub fn replace<'a, P: Pattern<'a>>(&'a self, from: P, to: &str) -> String {
@@ -246,6 +247,7 @@ impl str {
     /// let s = "this is old";
     /// assert_eq!(s, s.replacen("cookie monster", "little lamb", 10));
     /// ```
+    #[must_use]
     #[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