#Tokenizing and iterating over a string at comptime

1 messages · Page 1 of 1 (latest)

gritty zenith
#

it is a runtime variable. You need to explicitely make it comptime:

comptime var it = ...;
gritty zenith
#

You need to also mark the function call comptime:

inline while (comptime it.next()) ...
#

You could also put the entire thing in a comptime block, if you don't want to write comptime in front of everything:

comptime {
    var it = std.mem.tokenize(u8, pattern, "*");
    inline while (it.next()) |substr| {
        // ...
    }
}