-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Open
Labels
proposalThis issue suggests modifications. If it also has the "accepted" label then it is planned.This issue suggests modifications. If it also has the "accepted" label then it is planned.standard libraryThis issue involves writing Zig code for the standard library.This issue involves writing Zig code for the standard library.
Milestone
Description
Currently BufMap.set(key, value) copies the value and stores it, but it only returns errors. BufMap is probably being used because value won't live long and a copy is desired for further processing. So now you might need to do this:
fn saveValue(key: []u8, value: []const u8) ![]const u8 {
try map.set(key, value);
if (map.get(key)) |v| {
storePointer(v);
return v;
}
unreachable;
}If set would return the copy one could do this instead:
fn saveValue(key: []u8, value: []const u8) ![]const u8 {
const v = try map.set(key, value);
storePointer(v);
return v;
}BTW I've just started using Zig last week so I could certainly be missing something in how this is supposed to be used.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
proposalThis issue suggests modifications. If it also has the "accepted" label then it is planned.This issue suggests modifications. If it also has the "accepted" label then it is planned.standard libraryThis issue involves writing Zig code for the standard library.This issue involves writing Zig code for the standard library.