Skip to content

Commit

Permalink
Clarify the guarantees of Vec::as_ptr and Vec::as_mut_ptr when there'…
Browse files Browse the repository at this point in the history
…s no allocation
  • Loading branch information
SkiFire13 committed May 29, 2022
1 parent 512a328 commit 8ef2dd7
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions library/alloc/src/vec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1107,7 +1107,8 @@ impl<T, A: Allocator> Vec<T, A> {
self
}

/// Returns a raw pointer to the vector's buffer.
/// Returns a raw pointer to the vector's buffer, or a dangling raw pointer
/// valid for zero sized reads if the vector didn't allocate.
///
/// The caller must ensure that the vector outlives the pointer this
/// function returns, or else it will end up pointing to garbage.
Expand Down Expand Up @@ -1144,7 +1145,8 @@ impl<T, A: Allocator> Vec<T, A> {
ptr
}

/// Returns an unsafe mutable pointer to the vector's buffer.
/// Returns an unsafe mutable pointer to the vector's buffer, or a dangling
/// raw pointer valid for zero sized reads if the vector didn't allocate.
///
/// The caller must ensure that the vector outlives the pointer this
/// function returns, or else it will end up pointing to garbage.
Expand Down

0 comments on commit 8ef2dd7

Please sign in to comment.