diff options
| author | Seo Sanghyeon <sanxiyn@gmail.com> | 2017-01-10 20:27:48 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-01-10 20:27:48 +0900 |
| commit | db74f11f78e13fe2bbfb4e284c832d520fa5cf87 (patch) | |
| tree | ffa2c2c7fbc25c4c6e6684d28f98331c78e2779d /src | |
| parent | 8ccb3ef5ee443e8541c47beba1099944a1ac8807 (diff) | |
| parent | 0a85d5f7f355e7e04e97e27e2613c9831daa67a7 (diff) | |
| download | rust-db74f11f78e13fe2bbfb4e284c832d520fa5cf87.tar.gz rust-db74f11f78e13fe2bbfb4e284c832d520fa5cf87.zip | |
Rollup merge of #38874 - derekdreery:patch-1, r=steveklabnik
Update vec.rs Add a warning not to convert char* from c to Vec<u8> (I thought you could until I asked on irc). Reasoning is that it will help people avoid an error that could cause crashes and undefined behaviour. Only drawback is that it could confuse someone not familiar with C, but beginners are unlikely to be using this function anyway.
Diffstat (limited to 'src')
| -rw-r--r-- | src/libcollections/vec.rs | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/libcollections/vec.rs b/src/libcollections/vec.rs index 36dfc6b3e29..27cf0268c99 100644 --- a/src/libcollections/vec.rs +++ b/src/libcollections/vec.rs @@ -370,7 +370,8 @@ impl<T> Vec<T> { /// * `capacity` needs to be the capacity that the pointer was allocated with. /// /// Violating these may cause problems like corrupting the allocator's - /// internal datastructures. + /// internal datastructures. For example it is **not** safe + /// to build a `Vec<u8>` from a pointer to a C `char` array and a `size_t`. /// /// The ownership of `ptr` is effectively transferred to the /// `Vec<T>` which may then deallocate, reallocate or change the |
