-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Add CStr::from_bytes #1264
Comments
Ooh, big 👍. I've on occasion written my own |
IMO this should be implemented in a crate but not Is there some use case for CStr when writing solely in rust? |
|
Add a CStr::from_bytes function with a following API (or something along the lines):
Which converts a bytestring with a trailing null byte to a C string slice. If the slice does not have a trailing null byte or has a null byte in any position that’s not the last byte appropriate error is returned.
This is useful in APIs where a
&CStr
is expected and you can/want to pass in a static string (e.g.b"helloworld\0"
).The text was updated successfully, but these errors were encountered: