mirror of
https://github.com/rust-lang/rust
synced 2024-10-14 04:23:37 +00:00
vec: take [mutable? T] instead of [T]
This commit is contained in:
parent
230b279b82
commit
b0278f5315
|
@ -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));
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue