about summary refs log tree commit diff
path: root/library/alloc/src/string.rs
diff options
context:
space:
mode:
authorJohn Kugelman <john@kugelman.name>2021-10-12 19:09:24 -0400
committerJohn Kugelman <john@kugelman.name>2021-10-12 23:27:17 -0400
commit21f467774415b9f237bf1d0ece7236beb2e198a3 (patch)
treef4cff9ea096f54d3550857c84d9c7339396f8942 /library/alloc/src/string.rs
parent044674337a180c494b7e6fdce4b20dca93324b2a (diff)
Add #[must_use] to expensive computations
The unifying theme for this commit is weak, admittedly. I put together a
list of "expensive" functions when I originally proposed this whole
effort, but nobody's cared about that criterion. Still, it's a decent
way to bite off a not-too-big chunk of work.

Given the grab bag nature of this commit, the messages I used vary quite
a bit.
Diffstat (limited to 'library/alloc/src/string.rs')
-rw-r--r--library/alloc/src/string.rs2
1 files changed, 2 insertions, 0 deletions
diff --git a/library/alloc/src/string.rs b/library/alloc/src/string.rs
index f479bf231b3..01ab562cefd 100644
--- a/library/alloc/src/string.rs
+++ b/library/alloc/src/string.rs
@@ -552,6 +552,7 @@ impl String {
     ///
     /// assert_eq!("Hello �World", output);
     /// ```
+    #[must_use]
     #[cfg(not(no_global_oom_handling))]
     #[stable(feature = "rust1", since = "1.0.0")]
     pub fn from_utf8_lossy(v: &[u8]) -> Cow<'_, str> {
@@ -646,6 +647,7 @@ impl String {
     ///            String::from_utf16_lossy(v));
     /// ```
     #[cfg(not(no_global_oom_handling))]
+    #[must_use]
     #[inline]
     #[stable(feature = "rust1", since = "1.0.0")]
     pub fn from_utf16_lossy(v: &[u16]) -> String {