Function array_utils::drift_to_end[][src]

pub fn drift_to_end<T, const SIZE: usize>(
    array: [T; SIZE],
    till: usize,
    margin: usize,
    fill: T
) -> [T; SIZE] where
    T: Copy

Create an array containing a slice of original array at the end of the array.

Floats a part of sized array with the range ..till to the end of the result array with margin elements after 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_end;

// Float the elements with indices `..3` to the end with a margin of `0` elements,
// filling in `42` for all new elements.
assert_eq!(drift_to_end([1, 2, 3, 0, 0, 0, 0], 3, 0, 42), [42, 42, 42, 42, 1, 2, 3]);

Notes

  • If till is equal to 0 the resulting buffer will be [fill; SIZE].
  • If margin is greater or equal to SIZE the resulting buffer will be [fill; SIZE].