Skip to content

Conversation

@djpohly
Copy link

@djpohly djpohly commented Mar 18, 2023

Since we happen to know the slice obtained for an "optarg" will be zero-terminated, it seems reasonable to include this information in the type.

I'm newer to Zig, so correct me if I'm wrong, but it seems to me that [:0]const u8 gives strictly more compile-time information than []const u8 without costing anything at runtime. In my case, it allowed me to use the returned arg directly with a system API imported from C.

Since we happen to know the slice obtained for an "optarg" will be
zero-terminated, it seems reasonable to include this information in the
type.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant