Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

express Option.arg as sentinel-terminated slice #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

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.

None yet

1 participant