On 11/7/12 10:55 AM, Niko Matsakis wrote:
Can a vector of object references have any empty slots? Or do empty
slots need to have some kind of dummy objects in them to avoid null
pointers?

You can use DVec<Option<@T>> if you want the slots to be nullable.

But note that, for uniquely-owned vectors (~[T]), it is possible to reserve empty slots beyond the real end of the vector, so that the common vec::push() operation (which is semantically just "consume the vector and return a new vector with the element added" but can be optimized into something more efficient if there's extra space) won't have to unconditionally reallocate and copy. If you're interested in doing this, the function is vec::reserve().

Patrick

_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to