#how to have allocator as a function arg?

1 messages · Page 1 of 1 (latest)

nova locust
#
fn ensure_input(a: Allocator, day: usize) !EnsureInputErrors {

this says Allocator is not defined

#

undeclared identifier Allocator

#

or do I create an allocator within a function?

shy ore
#

Allocator is a type defined within std, so you have to import it (std) and then use it as std.Allocator

nova locust
#

const std = @import("std");
fn ensure_input(a: std.Allocator, day: usize) !EnsureInputErrors {
src/main.zig:7:23: error: root source file struct 'std' has no member named 'Allocator'

shy ore
#

std.mem.Allocator

#

Sorry, it was a mistake

nova locust
#

ah yes thanks

#

now I see the pattern