diff options
| author | John Kugelman <john@kugelman.name> | 2021-10-30 22:58:27 -0400 |
|---|---|---|
| committer | John Kugelman <john@kugelman.name> | 2021-10-30 23:44:02 -0400 |
| commit | e129d49f88a69d4bb8cb0f45a0a674c17393f4e9 (patch) | |
| tree | b04e94e7af3aa049512a2dbdaa8ae8ca0c1583ff /library/std/src/ffi | |
| parent | e249ce6b2345587d6e11052779c86adbad626dff (diff) | |
| download | rust-e129d49f88a69d4bb8cb0f45a0a674c17393f4e9.tar.gz rust-e129d49f88a69d4bb8cb0f45a0a674c17393f4e9.zip | |
Add #[must_use] to remaining std functions (A-N)
Diffstat (limited to 'library/std/src/ffi')
| -rw-r--r-- | library/std/src/ffi/c_str.rs | 3 | ||||
| -rw-r--r-- | library/std/src/ffi/os_str.rs | 2 |
2 files changed, 5 insertions, 0 deletions
diff --git a/library/std/src/ffi/c_str.rs b/library/std/src/ffi/c_str.rs index b7822b40a7c..465bbae8631 100644 --- a/library/std/src/ffi/c_str.rs +++ b/library/std/src/ffi/c_str.rs @@ -1009,6 +1009,7 @@ impl NulError { /// let nul_error = CString::new("foo bar\0").unwrap_err(); /// assert_eq!(nul_error.nul_position(), 7); /// ``` + #[must_use] #[stable(feature = "rust1", since = "1.0.0")] pub fn nul_position(&self) -> usize { self.0 @@ -1107,6 +1108,7 @@ impl IntoStringError { } /// Access the underlying UTF-8 error that was the cause of this error. + #[must_use] #[stable(feature = "cstring_into", since = "1.7.0")] pub fn utf8_error(&self) -> Utf8Error { self.error @@ -1456,6 +1458,7 @@ impl CStr { /// let boxed = c_string.into_boxed_c_str(); /// assert_eq!(boxed.into_c_string(), CString::new("foo").expect("CString::new failed")); /// ``` + #[must_use = "`self` will be dropped if the result is not used"] #[stable(feature = "into_boxed_c_str", since = "1.20.0")] pub fn into_c_string(self: Box<CStr>) -> CString { let raw = Box::into_raw(self) as *mut [u8]; diff --git a/library/std/src/ffi/os_str.rs b/library/std/src/ffi/os_str.rs index 46c9aa5e627..d3a3e5262f9 100644 --- a/library/std/src/ffi/os_str.rs +++ b/library/std/src/ffi/os_str.rs @@ -239,6 +239,7 @@ impl OsString { /// assert!(os_string.capacity() >= 10); /// ``` #[stable(feature = "osstring_simple_functions", since = "1.9.0")] + #[must_use] #[inline] pub fn capacity(&self) -> usize { self.inner.capacity() @@ -707,6 +708,7 @@ impl OsStr { /// Converts a <code>[Box]<[OsStr]></code> into an [`OsString`] without copying or allocating. #[stable(feature = "into_boxed_os_str", since = "1.20.0")] + #[must_use = "`self` will be dropped if the result is not used"] pub fn into_os_string(self: Box<OsStr>) -> OsString { let boxed = unsafe { Box::from_raw(Box::into_raw(self) as *mut Slice) }; OsString { inner: Buf::from_box(boxed) } |
