pub fn normalize_axes(
axes: &[isize],
rank: usize,
) -> Result<TinyVec<[usize; 8]>, ValidationError>Expand description
Normalize a list of signed axes against rank, rejecting duplicates.
The result keeps the order of axes. Two entries that name the same axis
(for example 1 and -2 at rank 3) are a duplicate.
§Errors
Returns ValidationError::AxisOutOfBounds for the first entry outside
-rank..rank, and ValidationError::DuplicateAxis (role "axes",
normalized index) for the first repeated axis.
§Examples
use tenferro_tensor_core::{normalize_axes, ValidationError};
assert_eq!(normalize_axes(&[0, -1], 3).unwrap().as_slice(), &[0, 2]);
assert_eq!(
normalize_axes(&[1, -2], 3),
Err(ValidationError::DuplicateAxis { axis: 1, role: "axes" })
);