Function lastIndexOfScalar [src]
Linear search for the last index of a scalar value inside a slice.
Prototype
pub fn lastIndexOfScalar(comptime T: type, slice: []const T, value: T) ?usize
Parameters
T: type
slice: []const T
value: T
Source
pub fn lastIndexOfScalar(comptime T: type, slice: []const T, value: T) ?usize {
var i: usize = slice.len;
while (i != 0) {
i -= 1;
if (slice[i] == value) return i;
}
return null;
}