On Tuesday, 4 October 2022 at 15:42:21 UTC, Steven Schveighoffer wrote:
Yes, you use `assumeSafeAppend`:

```d
arr.length--;
arr.assumeSafeAppend;
assert(arr.capacity != 0);
```

Now, I want to clarify that you should only use this if you are sure you are done with the data you removed at the end, as it will get overwritten upon more appends to the array.

[...]

Thanks! I can use the unstable `remove` and then restore the original capacity with `assumeSafeAppend` in case data can be safely overwritten.

The inherent reason for `remove` to cancel previous capacity and requiring new allocations is exactly to prevent overwriting data that could be owned by something else?

Reply via email to