about summary refs log tree commit diff
path: root/library/std/src
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2021-10-31 13:20:05 +0100
committerGitHub <noreply@github.com>2021-10-31 13:20:05 +0100
commit88e5ae2dd3cf4a0bbb5af69ef70e80d5dc7b462c (patch)
tree2b75ed54b12905fbfd24ed552d20956ded93847f /library/std/src
parent6c5aa765fb64758825fae0371b54ef07c3589e7a (diff)
parent6745e8da06e1fd313d2ff20ff9fe8d8dc4714479 (diff)
downloadrust-88e5ae2dd3cf4a0bbb5af69ef70e80d5dc7b462c.tar.gz
rust-88e5ae2dd3cf4a0bbb5af69ef70e80d5dc7b462c.zip
Rollup merge of #89786 - jkugelman:must-use-len-and-is_empty, r=joshtriplett
Add #[must_use] to len and is_empty

Parent issue: #89692

r? `@joshtriplett`
Diffstat (limited to 'library/std/src')
-rw-r--r--library/std/src/ffi/os_str.rs2
-rw-r--r--library/std/src/fs.rs1
-rw-r--r--library/std/src/os/unix/net/ancillary.rs2
3 files changed, 5 insertions, 0 deletions
diff --git a/library/std/src/ffi/os_str.rs b/library/std/src/ffi/os_str.rs
index 49e268eb99b..d7587e85c66 100644
--- a/library/std/src/ffi/os_str.rs
+++ b/library/std/src/ffi/os_str.rs
@@ -669,6 +669,7 @@ impl OsStr {
     /// assert!(!os_str.is_empty());
     /// ```
     #[stable(feature = "osstring_simple_functions", since = "1.9.0")]
+    #[must_use]
     #[inline]
     pub fn is_empty(&self) -> bool {
         self.inner.inner.is_empty()
@@ -700,6 +701,7 @@ impl OsStr {
     /// assert_eq!(os_str.len(), 3);
     /// ```
     #[stable(feature = "osstring_simple_functions", since = "1.9.0")]
+    #[must_use]
     #[inline]
     pub fn len(&self) -> usize {
         self.inner.inner.len()
diff --git a/library/std/src/fs.rs b/library/std/src/fs.rs
index 2b76a411a0f..69eca507c71 100644
--- a/library/std/src/fs.rs
+++ b/library/std/src/fs.rs
@@ -1080,6 +1080,7 @@ impl Metadata {
     ///     Ok(())
     /// }
     /// ```
+    #[must_use]
     #[stable(feature = "rust1", since = "1.0.0")]
     pub fn len(&self) -> u64 {
         self.0.size()
diff --git a/library/std/src/os/unix/net/ancillary.rs b/library/std/src/os/unix/net/ancillary.rs
index 57bb61903c1..353bf2f1166 100644
--- a/library/std/src/os/unix/net/ancillary.rs
+++ b/library/std/src/os/unix/net/ancillary.rs
@@ -431,12 +431,14 @@ impl<'a> SocketAncillary<'a> {
     }
 
     /// Returns `true` if the ancillary data is empty.
+    #[must_use]
     #[unstable(feature = "unix_socket_ancillary_data", issue = "76915")]
     pub fn is_empty(&self) -> bool {
         self.length == 0
     }
 
     /// Returns the number of used bytes.
+    #[must_use]
     #[unstable(feature = "unix_socket_ancillary_data", issue = "76915")]
     pub fn len(&self) -> usize {
         self.length