]> git.lizzy.rs Git - rust.git/blobdiff - library/alloc/src/string.rs
Auto merge of #96602 - TApplencourt:patch-1, r=Mark-Simulacrum
[rust.git] / library / alloc / src / string.rs
index e97c1637fd5a26fea0b4674e7e7de6419d363ac5..2272c5b7330dc872b0386646fecb655288061c1b 100644 (file)
@@ -770,7 +770,10 @@ pub fn into_raw_parts(self) -> (*mut u8, usize, usize) {
     /// * The first `length` bytes at `buf` need to be valid UTF-8.
     ///
     /// Violating these may cause problems like corrupting the allocator's
-    /// internal data structures.
+    /// internal data structures. For example, it is normally **not** safe to
+    /// build a `String` from a pointer to a C `char` array containing UTF-8
+    /// _unless_ you are certain that array was originally allocated by the
+    /// Rust standard library's allocator.
     ///
     /// The ownership of `buf` is effectively transferred to the
     /// `String` which may then deallocate, reallocate or change the