pub trait ArrayAdd<T, const N: usize>: Sized {
    fn append(self, e: T) -> [T; { _ }];
    fn append_back(self, e: T) -> [T; { _ }];
    fn concat<const L: usize>(self, array: [T; L]) -> [T; { _ }];
    fn concat_back<const L: usize>(self, array: [T; L]) -> [T; { _ }];
}
Expand description

Holds the append methods. Will (probably) get into core when generic-const-exprs becomes complete.

Required Methods

Inserts an element at the end of Self. Use concat for >1 elements. In order to avoid unnecessary calls to memcpy().

Examples
use array_manipulation::ArrayAdd;

let array: [u8; 4] = [1, 2, 3, 4];
let expected = [1, 2, 3, 4, 5];
let result = array.append(5);
assert_eq!(expected, result);

Inserts an element at the start of Self. Use concat for >1 elements. In order to avoid unnecessary calls to memcpy().

Examples
use array_manipulation::ArrayAdd;

let array: [u8; 4] = [1, 2, 3, 4];
let expected = [0, 1, 2, 3, 4];
let result = array.append_back(0);
assert_eq!(expected, result);

Takes an array of L elements and appends it at the end of Self. Performs 2 calls to memcpy(), so if your code heavily uses it maybe a linked list is a better fit for your use case.

Examples
use array_manipulation::ArrayAdd;

let array: [u8; 4] = [1, 2, 3, 4];
let expected = [1, 2, 3, 4, 5, 6, 7];
let result = array.concat([5, 6, 7]);
assert_eq!(expected, result);

Takes an array of L elements and appends it at the end of Self. Performs 2 calls to memcpy(), so if your code heavily uses it maybe a linked list is a better fit for your use case.

Examples
use array_manipulation::ArrayAdd;

let array: [u8; 4] = [1, 2, 3, 4];
let expected = [254, 255, 0, 1, 2, 3, 4];
let result = array.concat_back([254, 255, 0]);
assert_eq!(expected, result);

Implementations on Foreign Types

Implementors