-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Open
Description
In the standard library, std.mem.Allocator has the dupeZ method, which provides no flexibility. Changing it to dupeSentinel could be a "Zig style" option that increases maintainability and code flexibility.
The dupeSentinel method should look like this:
pub fn dupeSentinel(allocator: Allocator, comptime T: type, m: []const u8, comptime s: T) Error![:s]T {
const new_buf = try allocator.alloc(T, m.len + 1);
@memcpy(new_buf[0..m.len], m);
new_buf[m.len] = s;
return new_buf[0..m.len :s];
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels