Skip to content

with_capacity_align_from_uninit_bytes #16

@h33p

Description

@h33p

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions