Zig 0.16: trim start/end

This commit is contained in:
LN Liberda 2026-05-22 20:38:08 +02:00
parent e4b3c4d4c2
commit dfffa681c1
2 changed files with 2 additions and 2 deletions

View file

@ -55,7 +55,7 @@ const Pattern = struct {
}
fn parse(pat_: []const u8) *const Pattern {
var pat = std.mem.trimLeft(u8, pat_, "/");
var pat = std.mem.trimStart(u8, pat_, "/");
const top = main.allocator.create(Pattern) catch unreachable;
var tail = top;
tail.sub = null;

View file

@ -193,7 +193,7 @@ pub fn expanduser(path: []const u8, alloc: std.mem.Allocator, environ_map: *std.
break :blk std.mem.span(p);
return alloc.dupeZ(u8, path);
};
const home = std.mem.trimRight(u8, home_raw, "/");
const home = std.mem.trimEnd(u8, home_raw, "/");
if (home.len == 0 and path.len == len) return alloc.dupeZ(u8, "/");
return try std.mem.concatWithSentinel(alloc, u8, &.{ home, path[len..] }, 0);