#how to check if anytype matches conditions
1 messages · Page 1 of 1 (latest)
You can get the typeinfo at comptime with @typeInfo(@TypeOf(arg)), where arg is an anytype arg
what would I do to stop compilation in case it doesn't match?
You can use a combination of @typeInfo, @hasDecl, and @hasField. Or you can just use it as given and let the compiler error if there's something missing
There's @compileError
oh the compiler checks that? thats neat
Well, yeah. If a function takes anytype and tries to use the method foo, but a type without foo is passed, then the compiler has to error