diff options
| author | John Kugelman <john@kugelman.name> | 2021-10-11 13:57:38 -0400 |
|---|---|---|
| committer | John Kugelman <john@kugelman.name> | 2021-10-11 13:57:38 -0400 |
| commit | 06e625f7d582601f5e2ff69ba80f6d3a11632b24 (patch) | |
| tree | d2b9b88fb89cf0f074feeaa191cb9e22a4a9eee5 /library/alloc/src/string.rs | |
| parent | 86d6d2b7389fe1b339402c1798edae8b695fc9ef (diff) | |
| download | rust-06e625f7d582601f5e2ff69ba80f6d3a11632b24.tar.gz rust-06e625f7d582601f5e2ff69ba80f6d3a11632b24.zip | |
Add #[must_use] to as_type conversions
Diffstat (limited to 'library/alloc/src/string.rs')
| -rw-r--r-- | library/alloc/src/string.rs | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/library/alloc/src/string.rs b/library/alloc/src/string.rs index d00792b9c3e..4be8dddeda8 100644 --- a/library/alloc/src/string.rs +++ b/library/alloc/src/string.rs @@ -800,6 +800,7 @@ impl String { /// assert_eq!("foo", s.as_str()); /// ``` #[inline] + #[must_use] #[stable(feature = "string_as_str", since = "1.7.0")] pub fn as_str(&self) -> &str { self @@ -820,6 +821,7 @@ impl String { /// assert_eq!("FOOBAR", s_mut_str); /// ``` #[inline] + #[must_use] #[stable(feature = "string_as_str", since = "1.7.0")] pub fn as_mut_str(&mut self) -> &mut str { self @@ -1160,6 +1162,7 @@ impl String { /// assert_eq!(&[104, 101, 108, 108, 111], s.as_bytes()); /// ``` #[inline] + #[must_use] #[stable(feature = "rust1", since = "1.0.0")] pub fn as_bytes(&self) -> &[u8] { &self.vec @@ -1763,6 +1766,7 @@ impl FromUtf8Error { /// /// assert_eq!(&[0, 159], value.unwrap_err().as_bytes()); /// ``` + #[must_use] #[stable(feature = "from_utf8_error_as_bytes", since = "1.26.0")] pub fn as_bytes(&self) -> &[u8] { &self.bytes[..] @@ -2779,6 +2783,7 @@ impl<'a> Drain<'a> { /// let _ = drain.next().unwrap(); /// assert_eq!(drain.as_str(), "bc"); /// ``` + #[must_use] #[stable(feature = "string_drain_as_str", since = "1.55.0")] pub fn as_str(&self) -> &str { self.iter.as_str() |
