How to check if something is a string?

There used to be such a function, but it and lot of other meta stuff was removed from the standard library. You can take a look at the old implementation of isZigString in meta/trait.zig in the commit I linked.

I believe the Zig intended way to do what you are after is to just use the anytype variable as if is coercible to []const u8 and let the type system produce compilation errors when a non-string is passed. Whether those errors are always good errors is a work in progress.

3 Likes