Skip to content

Commit a09d90f

Browse files
committed
Clarify the guarantees of Vec::as_ptr and Vec::as_mut_ptr when there's no allocation
1 parent 233d1b5 commit a09d90f

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

alloc/src/vec/mod.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -1107,7 +1107,8 @@ impl<T, A: Allocator> Vec<T, A> {
11071107
self
11081108
}
11091109

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

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

0 commit comments

Comments
 (0)