rust-embedded / heapless

Heapless, `static` friendly data structures
Apache License 2.0
1.56k stars 185 forks source link

[construct|deconstruct] Vec/String [from|to] length + [MaybeUninit<T>; N] #507

Open Felix-El opened 3 months ago

Felix-El commented 3 months ago

These operations, let's call them from_parts / into_parts, I believe would be quite useful to allow the payload to change owners/container types without moving the data.

I don't think into_array<M>() can achieve the same because one has to statically know the exact runtime size. I thought about permitting M to be up to the capacity N but into_array would then have to pad the unused remaining space, which may be quite inefficient.

What are the chances of such MR to be accepted?

Dirbaio commented 3 months ago

I believe would be quite useful to allow the payload to change owners/container types without moving the data.

functions taking or returning the full [MaybeUninit<T>; N] will still move the data, I'm not sure if adding these functions will allow any performance improvements.