about summary refs log tree commit diff
diff options
context:
space:
mode:
authorGiacomo Stevanato <giaco.stevanato@gmail.com>2022-05-29 17:43:35 +0200
committerGiacomo Stevanato <giaco.stevanato@gmail.com>2022-05-29 17:43:35 +0200
commit8ef2dd70e6dc90a8895ca5000a2868e411ba34b7 (patch)
treec4b724b31880acf5ecb52e2f21dc74c92fc1fd72
parent512a328e2fb32bddd206461770a2c058368519cc (diff)
downloadrust-8ef2dd70e6dc90a8895ca5000a2868e411ba34b7.tar.gz
rust-8ef2dd70e6dc90a8895ca5000a2868e411ba34b7.zip
Clarify the guarantees of Vec::as_ptr and Vec::as_mut_ptr when there's no allocation
-rw-r--r--library/alloc/src/vec/mod.rs6
1 files changed, 4 insertions, 2 deletions
diff --git a/library/alloc/src/vec/mod.rs b/library/alloc/src/vec/mod.rs
index 3dc8a4fbba8..9621ca0eee0 100644
--- a/library/alloc/src/vec/mod.rs
+++ b/library/alloc/src/vec/mod.rs
@@ -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.
@@ -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.