Error: struct 'array_list.Aligned(u8,null)' has no member named 'init'

Here is the code snippet I’m trying to get to work again after 0.15.1 landed:

var buffer = std.ArrayList(u8).init(allocator);
try buffer.appendSlice(fragment);

It results in this error now:

error: struct 'array_list.Aligned(u8,null)' has no member named 'init'

Where was I supposed to find the migration information? I read the release notes and I see a note on managed vs unamanged, but it is still lost on me how to make this work.

Or to put a different way, what is the current best example of building a string of unknown length?

It is part of zig 0.15.1 release notes.

Thank you.

var buffer = std.array_list.Managed(u8).init(allocator);

seems to be what is needed.

1 Like

Note that the managed versions will be removed in a future release, so you’ll need to adapt your code to using unmanaged collections.

2 Likes

Example of how you’d do that:

var buffer: std.ArrayList(u8) = .empty;
defer buffer.deinit(allocator);

try buffer.appendSlice(allocator, fragment);
2 Likes