From f6be6aa92acd34d3a8815e29bb09b7ec2a72fedc Mon Sep 17 00:00:00 2001 From: Jake Goulding Date: Sun, 17 Jul 2016 10:52:59 -0400 Subject: [PATCH 1/2] Document from_raw_parts involves ownership transfer --- src/libcollections/string.rs | 6 ++++++ src/libcollections/vec.rs | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/src/libcollections/string.rs b/src/libcollections/string.rs index eedf4c2c11f34..8ba5c6ffbf2eb 100644 --- a/src/libcollections/string.rs +++ b/src/libcollections/string.rs @@ -701,6 +701,12 @@ impl String { /// Violating these may cause problems like corrupting the allocator's /// internal datastructures. /// + /// The ownership of `ptr` 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 + /// function. + /// /// # Examples /// /// Basic usage: diff --git a/src/libcollections/vec.rs b/src/libcollections/vec.rs index da56b21cf0c05..98b5c4663cd06 100644 --- a/src/libcollections/vec.rs +++ b/src/libcollections/vec.rs @@ -348,6 +348,12 @@ impl Vec { /// Violating these may cause problems like corrupting the allocator's /// internal datastructures. /// + /// The ownership of `ptr` is effectively transferred to the + /// `Vec` 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 + /// function. + /// /// # Examples /// /// ``` From 661187a95eb9b00a4a120de7d22ee28706574656 Mon Sep 17 00:00:00 2001 From: Jake Goulding Date: Sun, 17 Jul 2016 10:55:00 -0400 Subject: [PATCH 2/2] Remove extraneous words --- src/libcollections/vec.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libcollections/vec.rs b/src/libcollections/vec.rs index 98b5c4663cd06..3c221f0fea0df 100644 --- a/src/libcollections/vec.rs +++ b/src/libcollections/vec.rs @@ -342,7 +342,7 @@ impl Vec { /// /// * `ptr` needs to have been previously allocated via `String`/`Vec` /// (at least, it's highly likely to be incorrect if it wasn't). - /// * `length` needs to be the length that less than or equal to `capacity`. + /// * `length` needs to be less than or equal to `capacity`. /// * `capacity` needs to be the capacity that the pointer was allocated with. /// /// Violating these may cause problems like corrupting the allocator's