Function array_utils::drift_to_begin [−][src]
pub fn drift_to_begin<T, const SIZE: usize>(
array: [T; SIZE],
from: usize,
margin: usize,
fill: T
) -> [T; SIZE] where
T: Copy,
Create an array containing a slice of original array at the beginning of the array.
Floats a part of sized array
with the range from..
to the beginning of the result array
with margin
elements before the slice. All elements (including the margin) not filled with
the slice will be filled with the fill
value.
Examples
use array_utils::drift_to_begin; // Float the elements with indices `0..` to the beginning with a margin of `1` elements, // filling in `0x00` for all new elements. assert_eq!(drift_to_begin([1, 2, 3, 0, 0, 0, 0], 0, 1, 0x00), [0, 1, 2, 3, 0, 0, 0]);
Notes
- If
till
is equal to0
the resulting buffer will be[fill; SIZE]
. - If
margin
is greater or equal toSIZE
the resulting buffer will be[fill; SIZE]
.