Skip to content

Commit

Permalink
Auto merge of #74741 - aticu:master, r=jonas-schievink
Browse files Browse the repository at this point in the history
Improve documentation of `String::from_raw_parts`
  • Loading branch information
bors committed Jul 25, 2020
2 parents 0e11fc8 + 44d8b4c commit 73ca84d
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/liballoc/string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 73ca84d

Please sign in to comment.