array-appendarray-append exports a small family of functions for working with
const-generic array types:
concat which concatenates two arrayspush_right and push_left which add an element to the end or
beginning of an array respectivelysplit and split_end which split an array into two arrayspop_right and pop_left which separate the last or first element
respectively from an arrayAnd a few aliases:
push/pop for push_right/pop_right respectivelyunshift/shift for push_left/pop_left respectivelyThis library requires a nightly compiler due to the use of
#![feature(generic_const_exprs)]. All unsafe code has been verified to be
sound by manual proof and Miri.
This library does not yet require the standard library, but it is brought in
anyway unless the std default feature is disabled. This is for
forward-compatibility in case std-dependent code is ever added.
Create a no-alloc builder:
```rust
use array_append::push;
struct Built
struct Builder
impl Builder<0> { pub fn new() -> Self { Self { whatever: [] } } }
impl
pub fn with_usize(self, new: usize) -> Builder<{N + 1}> {
// Can't use `Self` here, because `Self` is `Builder<N>`
Builder { whatever: push(self.whatever, new) }
}
pub fn build(self) -> Built<N> {
Built { whatever: self.whatever }
}
}
asserteq!( Builder::new() .withusize(1) .withusize(2) .withusize(3) .build(), Builder::from_array([1, 2, 3]).build() ); ```