about summary refs log tree commit diff
path: root/src/liballoc/string.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2020-07-25 12:17:21 +0000
committerbors <bors@rust-lang.org>2020-07-25 12:17:21 +0000
commit73ca84dfa1388dc8628ecb5e28bc8433fbc8b727 (patch)
tree45abcb9ba1eb41b121db720752cee740c14793ce /src/liballoc/string.rs
parent0e11fc8053d32c44e7152865852acc5c3c54efb3 (diff)
parent44d8b4c8b12be337156d8e21ca8103ef9704840e (diff)
downloadrust-73ca84dfa1388dc8628ecb5e28bc8433fbc8b727.tar.gz
rust-73ca84dfa1388dc8628ecb5e28bc8433fbc8b727.zip
Auto merge of #74741 - aticu:master, r=jonas-schievink
Improve documentation of `String::from_raw_parts`
Diffstat (limited to 'src/liballoc/string.rs')
-rw-r--r--src/liballoc/string.rs5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/liballoc/string.rs b/src/liballoc/string.rs
index f41c8c5a559..05398ca68c8 100644
--- a/src/liballoc/string.rs
+++ b/src/liballoc/string.rs
@@ -667,15 +667,16 @@ impl String {
     /// This is highly unsafe, due to the number of invariants that aren't
     /// checked:
     ///
-    /// * The memory at `ptr` needs to have been previously allocated by the
+    /// * The memory at `buf` needs to have been previously allocated by the
     ///   same allocator the standard library uses, with a required alignment of exactly 1.
     /// * `length` needs to be less than or equal to `capacity`.
     /// * `capacity` needs to be the correct value.
+    /// * 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.
     ///
-    /// The ownership of `ptr` is effectively transferred to the
+    /// The ownership of `buf` is effectively transferred to the
     /// `String` which may then deallocate, reallocate or change the
     /// contents of memory pointed to by the pointer at will. Ensure
     /// that nothing else uses the pointer after calling this