Hi. I’m updating to 0.15 some code I wrote for 0.12. I’ve notice that the interface for ArrayList has changed, no keeping the reference for the allocator, and requiring it to be passed when appending data, like the below example. What was the motivation behind this change? Thanks for helping me to understand the evolution of Zig.
pub fn build_query(allocator: std.mem.Allocator, params: []Param) ![]u8 {
var response = try std.ArrayList(u8).initCapacity(allocator, 64);
for (params) |param| {
if (response.items.len > 0) {
try response.append(allocator, '&');
}
try response.appendSlice(allocator, param.name);
try response.append(allocator, '=');
try response.appendSlice(allocator, param.value);
}
return response.toOwnedSlice(allocator);
}