zig/std/str.zig
Andrew Kelley 7edef4f3fd add beginning of print stack trace function
introduce std.debug and move std.assert to std.debug.assert
add mem.copy
2016-05-17 13:32:43 -07:00

19 lines
431 B
Zig

const assert = @import("debug.zig").assert;
pub const eql = slice_eql(u8);
pub fn slice_eql(T: type)(a: []const T, b: []const T) -> bool {
if (a.len != b.len) return false;
for (a) |item, index| {
if (b[index] != item) return false;
}
return true;
}
#attribute("test")
fn string_equality() {
assert(eql("abcd", "abcd"));
assert(!eql("abcdef", "abZdef"));
assert(!eql("abcdefg", "abcdef"));
}