diff options
| author | Huon Wilson <dbau.pp+github@gmail.com> | 2014-03-20 01:52:37 +1100 |
|---|---|---|
| committer | Huon Wilson <dbau.pp+github@gmail.com> | 2014-03-22 09:54:18 +1100 |
| commit | e33676b7936b12bb68f47857ab3f8ea9b757d0d5 (patch) | |
| tree | 64e49bfdfb621bca44056fb4810c4f487f74940b /src/libstd/vec.rs | |
| parent | 0384952a657e49d1f1cbab7c21dee91cd2c4f585 (diff) | |
| download | rust-e33676b7936b12bb68f47857ab3f8ea9b757d0d5.tar.gz rust-e33676b7936b12bb68f47857ab3f8ea9b757d0d5.zip | |
Migrate all users of opt_vec to owned_slice, delete opt_vec.
syntax::opt_vec is now entirely unused, and so can go.
Diffstat (limited to 'src/libstd/vec.rs')
| -rw-r--r-- | src/libstd/vec.rs | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/libstd/vec.rs b/src/libstd/vec.rs index 5f4f4960a93..5138d33c17b 100644 --- a/src/libstd/vec.rs +++ b/src/libstd/vec.rs @@ -121,6 +121,19 @@ impl<T> Vec<T> { } } + /// Create a `Vec<T>` directly from the raw constituents. + /// + /// This is highly unsafe: + /// + /// - if `ptr` is null, then `length` and `capacity` should be 0 + /// - `ptr` must point to an allocation of size `capacity` + /// - there must be `length` valid instances of type `T` at the + /// beginning of that allocation + /// - `ptr` must be allocated by the default `Vec` allocator + pub unsafe fn from_raw_parts(length: uint, capacity: uint, ptr: *mut T) -> Vec<T> { + Vec { len: length, cap: capacity, ptr: ptr } + } + /// Consumes the `Vec`, partitioning it based on a predcate. /// /// Partitions the `Vec` into two `Vec`s `(A,B)`, where all elements of `A` |
