diff options
| author | John Kugelman <john@kugelman.name> | 2021-10-11 16:15:50 -0400 |
|---|---|---|
| committer | John Kugelman <john@kugelman.name> | 2021-10-30 19:25:12 -0400 |
| commit | 6745e8da06e1fd313d2ff20ff9fe8d8dc4714479 (patch) | |
| tree | 3e95126f0f29319c6c2ce80aef7fc275c1c33897 /library/std/src | |
| parent | 86d6d2b7389fe1b339402c1798edae8b695fc9ef (diff) | |
| download | rust-6745e8da06e1fd313d2ff20ff9fe8d8dc4714479.tar.gz rust-6745e8da06e1fd313d2ff20ff9fe8d8dc4714479.zip | |
Add #[must_use] to len and is_empty
Diffstat (limited to 'library/std/src')
| -rw-r--r-- | library/std/src/ffi/os_str.rs | 2 | ||||
| -rw-r--r-- | library/std/src/fs.rs | 1 | ||||
| -rw-r--r-- | library/std/src/os/unix/net/ancillary.rs | 2 |
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 f5cef60e126..ca0f27b285f 100644 --- a/library/std/src/ffi/os_str.rs +++ b/library/std/src/ffi/os_str.rs @@ -660,6 +660,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() @@ -691,6 +692,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 726c855c4fd..54b998d12ac 100644 --- a/library/std/src/fs.rs +++ b/library/std/src/fs.rs @@ -1077,6 +1077,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 1f9d42812ec..0ed3018c802 100644 --- a/library/std/src/os/unix/net/ancillary.rs +++ b/library/std/src/os/unix/net/ancillary.rs @@ -430,12 +430,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 |
