Function array_utils::splice[][src]

pub fn splice<T, const ORIGINAL_SIZE: usize, const LEFT_SIZE: usize, const RIGHT_SIZE: usize>(
    original: [T; ORIGINAL_SIZE],
    fill: T
) -> ([T; LEFT_SIZE], [T; RIGHT_SIZE]) where
    T: Copy

Splice a sized arrays together into a two arrays.

Create two arrays the left being filled up first, then the right. If the given original array is two small to fill both buffers, the fill value is used for the remaining elements.

Examples

use array_utils::splice;

assert_eq!(splice([1, 2, 3, 4, 5, 6], 0), ([1, 2, 3], [4, 5, 6]));

// Leftover elements are not used
assert_eq!(splice([1, 2, 3, 4, 5, 6, 0, 0], 0), ([1, 2, 3], [4, 5, 6]));

// If the `original` buffer is to small the remaining elements are filled in.
assert_eq!(splice([1, 2, 3, 4, 5], 0), ([1, 2, 3], [4, 5, 0]));