std.mem.trimLeft removes a set of values from the beginning of a slice, and std.mem.trimRight removes a set of values from the end of a slice.
In left-to-right scripts (most languages), these functions do exactly what their names suggest:
consts="日本語";
std.debug.print("{}\n", .{std.mem.eql(u8, "日本", std.mem.trimRight(u8, s, "語"))}); // trueBut in right-to-left scripts (such as Hebrew and Arabic), these functions do not work as their names suggest:
consts="עִבְרִית";
std.debug.print("{}\n", .{std.mem.eql(u8, "בְרִית", std.mem.trimRight(u8, s, "עִ"))}); // falsestd.debug.print("{}\n", .{std.mem.eql(u8, "עִבְרִי", std.mem.trimRight(u8, s, "ת"))}); // trueIn right-to-left scripts, the end of the string is on the left, so we specify the left characters to trimRight. I think this is strange. So I think it would be better to rename mem.trimLeft to mem.trimStart, and mem.trimRight to mem.trimEnd.
std.mem.trimLeftremoves a set of values from the beginning of a slice, andstd.mem.trimRightremoves a set of values from the end of a slice.In left-to-right scripts (most languages), these functions do exactly what their names suggest:
But in right-to-left scripts (such as Hebrew and Arabic), these functions do not work as their names suggest:
In right-to-left scripts, the end of the string is on the left, so we specify the left characters to
trimRight. I think this is strange. So I think it would be better to renamemem.trimLefttomem.trimStart, andmem.trimRighttomem.trimEnd.