pub fn evaluate_index_for_vector(
index: impl TryInto<i64> + Display,
vector_length: i64,
) -> Result<i64, MathError>Expand description
Evaluates whether the provided index is referencing an entry in a vector. Negative indices are allowed and reference entries form the end of the vector.
Parameters:
index: specifies the index in which the entry is locatedvector_length: specifies the length of the vector
Returns the index as an i64 if it references an entry and return
an error otherwise.
ยงErrors and Failures
- Returns a
MathErrorof typeMathError::OutOfBoundsif the index is not within the bounds of the vector.