From e7949bc2f41e710deb97f9e1da2a599563b1faf4 Mon Sep 17 00:00:00 2001 From: aticu <15schnic@gmail.com> Date: Sat, 25 Jul 2020 14:04:56 +0200 Subject: [PATCH 1/2] Fix wrong name in `String::from_raw_parts` docs --- src/liballoc/string.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/liballoc/string.rs b/src/liballoc/string.rs index f41c8c5a55910..798ab84069ad0 100644 --- a/src/liballoc/string.rs +++ b/src/liballoc/string.rs @@ -667,7 +667,7 @@ 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. @@ -675,7 +675,7 @@ impl String { /// 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 From 44d8b4c8b12be337156d8e21ca8103ef9704840e Mon Sep 17 00:00:00 2001 From: aticu <15schnic@gmail.com> Date: Sat, 25 Jul 2020 14:06:32 +0200 Subject: [PATCH 2/2] Document UTF-8 validity of String::from_raw_parts --- src/liballoc/string.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/liballoc/string.rs b/src/liballoc/string.rs index 798ab84069ad0..05398ca68c8ba 100644 --- a/src/liballoc/string.rs +++ b/src/liballoc/string.rs @@ -671,6 +671,7 @@ impl String { /// 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.