Vector.downsize

Downsizes the vector to a length of n elements.

If n is smaller than the current vector length, the current value is shortened to its first n character, removing the characters beyond the nth.

If n is greater than the current vector length, then nothing happend.

struct Vector
scope nothrow
void
downsize
()
(
const size_t n
)

Examples

Vector!(int, 6) vec = Vector!(int, 6).build(1, 2, 3);

vec.downsize(5);
assert(vec == [1, 2, 3]);

vec.downsize(2);
assert(vec == [1, 2]);

Meta