diff options
| author | kennytm <kennytm@gmail.com> | 2017-12-22 02:50:55 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-12-22 02:50:55 +0800 |
| commit | 7767d84a68bc90a49b409516c6aed480f2483be4 (patch) | |
| tree | 1d4509fbfee57c9c826bb62b6154417b4f6cf5dc /src/liballoc | |
| parent | 4802a853920d713e8d7815d7cb287116708d697c (diff) | |
| parent | 52c28fffa905752dadd1faab9d1332c0d1aa3c1a (diff) | |
| download | rust-7767d84a68bc90a49b409516c6aed480f2483be4.tar.gz rust-7767d84a68bc90a49b409516c6aed480f2483be4.zip | |
Rollup merge of #46884 - Manishearth:vec-docs, r=steveklabnik
Clarify vec docs on deallocation (fixes #46879) r? @steveklabnik
Diffstat (limited to 'src/liballoc')
| -rw-r--r-- | src/liballoc/vec.rs | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/liballoc/vec.rs b/src/liballoc/vec.rs index 67ccb5cab6d..93d7e66b7b2 100644 --- a/src/liballoc/vec.rs +++ b/src/liballoc/vec.rs @@ -224,8 +224,10 @@ use Bound::{Excluded, Included, Unbounded}; /// types inside a `Vec`, it will not allocate space for them. *Note that in this case /// the `Vec` may not report a [`capacity`] of 0*. `Vec` will allocate if and only /// if [`mem::size_of::<T>`]`() * capacity() > 0`. In general, `Vec`'s allocation -/// details are subtle enough that it is strongly recommended that you only -/// free memory allocated by a `Vec` by creating a new `Vec` and dropping it. +/// details are very subtle — if you intend to allocate memory using a `Vec` +/// and use it for something else (either to pass to unsafe code, or to build your +/// own memory-backed collection), be sure to deallocate this memory by using +/// `from_raw_parts` to recover the `Vec` and then dropping it. /// /// If a `Vec` *has* allocated memory, then the memory it points to is on the heap /// (as defined by the allocator Rust is configured to use by default), and its |
