Strings In Depth3 / 19
Up next

Compare with mem.eql

const std = @import("std");

pub fn main() void {
    const a = "rust";
    const b = "rust";
    // == on slices compares pointers, so use std.mem.eql for content
    std.debug.print("{}\n", .{std.mem.eql(u8, a, b)});
    std.debug.print("{}\n", .{std.mem.eql(u8, a, "zig")});
}
What you're solving

std.mem.eql tests byte equality