pub fn findDiff(comptime T: type, a: []const T, b: []const T) ?usize T: typea: []const Tb: []const T858
859
860
861
862
863
864
865
866
867pub fn findDiff(comptime T: type, a: []const T, b: []const T) ?usize {
const shorter = @min(a.len, b.len);
if (@typeInfo(T) != .float and a.ptr == b.ptr) {
return if (a.len == b.len) null else shorter;
}
for (a[0..shorter], b[0..shorter], 0..) |a_elem, b_elem, i| {
if (a_elem != b_elem) return i;
}
return if (a.len == b.len) null else shorter;
}
Compares two slices and returns the index of the first inequality. Returns null if the slices are equal.