I would say it would be incredibly useful to have such alignment function in cases where multiple vectors are to be allocated.
For instance, here, in our memflow project, we perform a series of slice splits to allocate the buffers, with intention of allocating that particular number of elements in each, rather than "just how many fit in the misaligned buf". This is particularly troublesome here, where the allocated buffer is expected to fit exactly that many elements. However, in some cases the split slice is misaligned, and the resulting capacity is zero (thus I had to add extra bytes in the split).
A with_capacity_align_from_uninit_bytes function (a really long name, would probably need something simpler) would try to align and split the slice to house just that particular amount of elements, while keeping the end to be freely used by other vecs.
If you think this is an useful feature, I could go ahead, add it in, and create a PR.
I would say it would be incredibly useful to have such alignment function in cases where multiple vectors are to be allocated.
For instance, here, in our memflow project, we perform a series of slice splits to allocate the buffers, with intention of allocating that particular number of elements in each, rather than "just how many fit in the misaligned buf". This is particularly troublesome here, where the allocated buffer is expected to fit exactly that many elements. However, in some cases the split slice is misaligned, and the resulting capacity is zero (thus I had to add extra bytes in the split).
A
with_capacity_align_from_uninit_bytesfunction (a really long name, would probably need something simpler) would try to align and split the slice to house just that particular amount of elements, while keeping the end to be freely used by other vecs.If you think this is an useful feature, I could go ahead, add it in, and create a PR.