vec: take [mutable? T] instead of [T]

This commit is contained in:
Elly Jones 2011-11-04 20:27:37 -04:00 committed by Brian Anderson
parent 230b279b82
commit b0278f5315

View file

@ -796,7 +796,7 @@ unsafe fn from_buf<T>(ptr: *T, elts: uint) -> [T] {
modifing its buffers, so it is up to the caller to ensure that
the vector is actually the specified size.
*/
unsafe fn set_len<T>(&v: [T], new_len: uint) {
unsafe fn set_len<T>(&v: [mutable? T], new_len: uint) {
let repr: **vec_repr = ::unsafe::reinterpret_cast(addr_of(v));
(**repr).fill = new_len * sys::size_of::<T>();
}
@ -812,7 +812,7 @@ unsafe fn set_len<T>(&v: [T], new_len: uint) {
Modifying the vector may cause its buffer to be reallocated, which
would also make any pointers to it invalid.
*/
unsafe fn to_ptr<T>(v: [T]) -> *T {
unsafe fn to_ptr<T>(v: [mutable? T]) -> *T {
let repr: **vec_repr = ::unsafe::reinterpret_cast(addr_of(v));
ret ::unsafe::reinterpret_cast(addr_of((**repr).data));
}