Function step

Source
pub fn step<R, S>(range: R, step: S) -> StepRange<R, S>
Expand description

Creates a range with the given step size from a unit spaced range.

If the step size is negative, the result is obtained by reversing the input range and stepping by the absolute value of the step size.

ยงExamples

use mdarray::{step, view};

let v = view![0, 1, 2, 3, 4, 5, 6, 7, 8, 9];

assert_eq!(v.view(step(0..10, 2)).to_vec(), [0, 2, 4, 6, 8]);
assert_eq!(v.view(step(0..10, -2)).to_vec(), [9, 7, 5, 3, 1]);