Skip to content

Commit 1132a4d

Browse files
authored
Rollup merge of #34884 - shepmaster:from_raw_parts_doc, r=@nagisa
Improve {String,Vec}::from_raw_parts documentation
2 parents b713849 + 661187a commit 1132a4d

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/libcollections/string.rs

+6
Original file line numberDiff line numberDiff line change
@@ -701,6 +701,12 @@ impl String {
701701
/// Violating these may cause problems like corrupting the allocator's
702702
/// internal datastructures.
703703
///
704+
/// The ownership of `ptr` is effectively transferred to the
705+
/// `String` which may then deallocate, reallocate or change the
706+
/// contents of memory pointed to by the pointer at will. Ensure
707+
/// that nothing else uses the pointer after calling this
708+
/// function.
709+
///
704710
/// # Examples
705711
///
706712
/// Basic usage:

src/libcollections/vec.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -342,12 +342,18 @@ impl<T> Vec<T> {
342342
///
343343
/// * `ptr` needs to have been previously allocated via `String`/`Vec<T>`
344344
/// (at least, it's highly likely to be incorrect if it wasn't).
345-
/// * `length` needs to be the length that less than or equal to `capacity`.
345+
/// * `length` needs to be less than or equal to `capacity`.
346346
/// * `capacity` needs to be the capacity that the pointer was allocated with.
347347
///
348348
/// Violating these may cause problems like corrupting the allocator's
349349
/// internal datastructures.
350350
///
351+
/// The ownership of `ptr` is effectively transferred to the
352+
/// `Vec<T>` which may then deallocate, reallocate or change the
353+
/// contents of memory pointed to by the pointer at will. Ensure
354+
/// that nothing else uses the pointer after calling this
355+
/// function.
356+
///
351357
/// # Examples
352358
///
353359
/// ```

0 commit comments

Comments
 (0)