-
Notifications
You must be signed in to change notification settings - Fork 12.5k
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
Creating CString from nul-terminated data #73100
Labels
A-ffi
Area: Foreign Function Interface (FFI)
C-feature-request
Category: A feature request, i.e: not implemented / a PR.
T-libs-api
Relevant to the library API team, which will review and decide on the PR/issue.
Comments
jonas-schievink
added
A-ffi
Area: Foreign Function Interface (FFI)
C-feature-request
Category: A feature request, i.e: not implemented / a PR.
T-libs-api
Relevant to the library API team, which will review and decide on the PR/issue.
labels
Jun 7, 2020
I can do it if the lib team is ok with it being added. |
Not a part of libs team but it seems like it covers a certain gap from std and I know that such PRs are definitely encouraged! |
This was referenced Jun 8, 2020
RalfJung
added a commit
to RalfJung/rust
that referenced
this issue
Jun 15, 2020
…nul, r=dtolnay Add methods to go from a nul-terminated Vec<u8> to a CString Fixes rust-lang#73100. Doc tests have been written and the documentation on the error type updated too. I used `#[stable(feature = "cstring_from_vec_with_nul", since = "1.46.0")]` but I don't know if the version is correct.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
A-ffi
Area: Foreign Function Interface (FFI)
C-feature-request
Category: A feature request, i.e: not implemented / a PR.
T-libs-api
Relevant to the library API team, which will review and decide on the PR/issue.
It seems there's no idiomatic way to create
CString
from nul-terminatedVec<u8>
. The only approriate way is topop()
last nul and thenfrom_vec_unchecked
will append a new one. Need the method just passes data as is (e.g.CString::from_vec_with_nul
such asCStr::from_bytes_with_nul
).Possibly, code should be like:
and safe version:
The text was updated successfully, but these errors were encountered: