1
Fork 0

auto merge of #13016 : huonw/rust/new-opt-vec, r=cmr

Replace syntax::opt_vec with syntax::owned_slice

The `owned_slice::OwnedSlice` is  `(*T, uint)` (i.e. a direct equivalent to DSTs `~[T]`).

This shaves two words off the old OptVec type; and also makes substituting in other implementations easy, by removing all the mutation methods. (And also everything that's very rarely/never used.)
This commit is contained in:
bors 2014-03-21 20:06:44 -07:00
commit f5357cf3ce
42 changed files with 369 additions and 451 deletions

View file

@ -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`