Function indexOfNone [src]
Find the first item in slice which is not contained in values.
Comparable to strspn in the C standard library.
Prototype
pub fn indexOfNone(comptime T: type, slice: []const T, values: []const T) ?usize
Parameters
T: type
slice: []const T
values: []const T
Example
test indexOfNone {
try testing.expect(indexOfNone(u8, "abc123", "123").? == 0);
try testing.expect(lastIndexOfNone(u8, "abc123", "123").? == 2);
try testing.expect(indexOfNone(u8, "123abc", "123").? == 3);
try testing.expect(lastIndexOfNone(u8, "123abc", "123").? == 5);
try testing.expect(indexOfNone(u8, "123123", "123") == null);
try testing.expect(indexOfNone(u8, "333333", "123") == null);
try testing.expect(indexOfNonePos(u8, "abc123", 3, "321") == null);
}
Source
pub fn indexOfNone(comptime T: type, slice: []const T, values: []const T) ?usize {
return indexOfNonePos(T, slice, 0, values);
}