Rollup merge of #34884 - shepmaster:from_raw_parts_doc, r=@nagisa

Improve {String,Vec}::from_raw_parts documentation
This commit is contained in:
Seo Sanghyeon 2016-07-18 22:44:56 +09:00 committed by GitHub
commit 1132a4ddfc
2 changed files with 13 additions and 1 deletions

View File

@ -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:

View File

@ -342,12 +342,18 @@ impl<T> Vec<T> {
///
/// * `ptr` needs to have been previously allocated via `String`/`Vec<T>`
/// (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
/// internal datastructures.
///
/// The ownership of `ptr` is effectively transferred to the
/// `Vec<T>` 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
///
/// ```