about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2021-10-26 14:44:47 +0000
committerbors <bors@rust-lang.org>2021-10-26 14:44:47 +0000
commit612356aa9a0193cb5aee2b668b3893ddf67da2b5 (patch)
tree7e39dfbbf03bbc01b6d082ea6ba7a87b42ad6396
parent3c8f001d454b1b495f7472d8430ef8fdf10aac11 (diff)
parent6b90c0f1b40966ff33bdbb8385357a958532fb8a (diff)
downloadrust-612356aa9a0193cb5aee2b668b3893ddf67da2b5.tar.gz
rust-612356aa9a0193cb5aee2b668b3893ddf67da2b5.zip
Auto merge of #90290 - nyanpasu64:fix-string-as-mut-vec, r=m-ou-se
Fix copy-paste error in String::as_mut_vec() docs

Did not expect the comments to be perfectly justified... can't wait to be told to change it to `Vec<u8>`, which destroys the justification 😼
-rw-r--r--library/alloc/src/string.rs9
1 files changed, 5 insertions, 4 deletions
diff --git a/library/alloc/src/string.rs b/library/alloc/src/string.rs
index f479bf231b3..85ee7ea9438 100644
--- a/library/alloc/src/string.rs
+++ b/library/alloc/src/string.rs
@@ -1500,10 +1500,11 @@ impl String {
     ///
     /// # Safety
     ///
-    /// This function is unsafe because it does not check that the bytes passed
-    /// to it are valid UTF-8. If this constraint is violated, it may cause
-    /// memory unsafety issues with future users of the `String`, as the rest of
-    /// the standard library assumes that `String`s are valid UTF-8.
+    /// This function is unsafe because the returned `&mut Vec` allows writing
+    /// bytes which are not valid UTF-8. If this constraint is violated, using
+    /// the original `String` after dropping the `&mut Vec` may violate memory
+    /// safety, as the rest of the standard library assumes that `String`s are
+    /// valid UTF-8.
     ///
     /// # Examples
     ///