#array #append #insert #insertion #vector

nightly no-std array_manipulation

Methods for manipuling arrays in a Vec-like fashion. It will (probably) get into core once const expressions get less experimental.

5 releases (3 breaking)

0.4.1 Jul 23, 2022
0.4.0 Jul 22, 2022
0.3.0 Jul 22, 2022
0.2.0 Jul 21, 2022
0.1.0 Jul 20, 2022

#2810 in Rust patterns

22 downloads per month

MIT license

187 lines

Manipulate Arrays as if they were vectors!

This crate exposes 2 traits that allow manipulating arrays in a vec-like fashion.

Alternatives like ArrayVec operate over a [MaybeUninit<T>; N]-like data structure and panic if the size is overflown. The point of this crate is allowing to "resize" arrays.

If you heavily depend on this crate, probably a linked list will be a much better fit, but this crate is still very useful for one-time operations, operations where using a linked list will give more problems than solutions, coercing arrays or devices where you can't allocate.

This crate works & performs exceptionally well when you have an array that you need to manipulate but you still need to use a fixed array later and not a Vec. In that situation you just avoided 1 malloc() & 3 memcpy()s best-case scenario and n malloc()s, 3 memcpy()s and a conditional worst-case scenario.

Merging into core

This crate depends on the experimental (not complete) feature generic-const-exprs, so the Pre-RFC is postponed until it doesn't get to a more mature state.

No runtime deps