#integer type to []const u8 (ascii string)
1 messages · Page 1 of 1 (latest)
@as only does type coercion when it is an explicit safe conversion that the compiler knows is always ok. For other stuff you need @bitCast or @ptrCast
basically you can only do @as(T, foo) when you could also instead do const bar: T = foo;
yeah, it probably meant that you need to use @as([4]u8, @bitCast(myInt)). It's a bit of an odd way of doing things, but it allows type inference in a lot of cases. Casts used to take the type to cast to as a parameter, but now you are supposed to use @as if you need to specify the type.