pub fn superimpose<T, const MAIN_SIZE: usize, const SUB_SIZE: usize>(
main_array: [T; MAIN_SIZE],
sub_array: [T; SUB_SIZE],
starting_from: usize,
) -> [T; MAIN_SIZE]where
T: Copy,
Expand description
Superimpose an sized sub_array
upon another main_array
at index starting_from
.
Create a copy of the main_array
and insert all elements of sub_array
into it,
starting from the starting_from
index. If the sub_array
has more elements than fit in the
main_array
they are ignored.
ยงExamples
use array_utils::superimpose;
assert_eq!(
superimpose([0; 8], [1, 3, 3, 7], 2),
[0, 0, 1, 3, 3, 7, 0, 0]
);
// Elements that don't fit in the main array size are ignored.
assert_eq!(
superimpose([1, 2, 3], [4, 2], 2),
[1, 2, 4]
);