pub fn range(
start: i32,
end: Option<i32>,
step: Option<i32>,
) -> Result<Vec<i32>, ArrayError>Expand description
Creates a range of integers from start to end (exclusive) with optional step.
§Arguments
start- The starting value of the rangeend- The ending value of the range (exclusive). If None, range is [0, start)step- The step size (default: 1)
§Returns
A vector containing the range values
§Errors
Returns ArrayError::ZeroStep if step is 0
§Examples
use mudssky_utils::array::range;
assert_eq!(range(5, None, None).unwrap(), vec![0, 1, 2, 3, 4]);
assert_eq!(range(1, Some(4), None).unwrap(), vec![1, 2, 3]);
assert_eq!(range(0, Some(10), Some(2)).unwrap(), vec![0, 2, 4, 6, 8]);
assert_eq!(range(10, Some(0), Some(-2)).unwrap(), vec![10, 8, 6, 4, 2]);