-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Tracking Issue for methods to go from nul-terminated Vec<u8> to CString #73179
Comments
@rustbot modify labels to T-libs, A-ffi, C-feature-request |
Couldn't there also be a |
Added in the current PR (#73139) Edit: As Dtolnay noted in this comment, there is not one unique behaviour that can be used for a |
A new error type has been added. It is explained in the original post. |
What is the path to stabilization for this feature? |
No one has noted any concerns and it has been unstable for quite some time now, if you want to stabilize it you can make a PR for it (be sure to ping me so I can update the tracking issue). |
I found competing documentation about stabilizing a library feature in the rustc-dev-guide and the std-dev-guide. The former seems more detailed, but out of date (I can't find any trace of an @T-libs-api team.) They do seem to agree that step 0 should be completing the FCP, so... @rust-lang/libs can we start the FCP for this feature? I'm happy to open the stabilization PR once that has been completed. |
I'm not certain any of my attempted team @-mentions are actually functioning, so I'm going to additionally cc @joshtriplett since they are a library team member and were randomly selected on the PR I'm prepping for this. |
Stabilizing this seems reasonable to me. @rfcbot merge |
Team member @joshtriplett has proposed to merge this. The next step is review by the rest of the tagged team members: No concerns currently listed. Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! See this document for info about what commands tagged team members can give me. |
🔔 This is now entering its final comment period, as per the review above. 🔔 |
The final comment period, with a disposition to merge, as per the review above, is now complete. As the automated representative of the governance process, I would like to thank the author for their work and everyone else who contributed. This will be merged soon. |
…_with_nul, r=JohnTitor Stabilize CString::from_vec_with_nul[_unchecked] Closes the tracking issue rust-lang#73179. I am keeping this in _draft_ mode until the FCP has ended. This is my first time stabilizing a feature, so I would appreciate any guidance on things I should do differently. Closes rust-lang#73179
The feature gate for the issue is
#![feature(cstring_from_vec_with_nul)]
.This adds the following method to
CString
:FromVecWithNulError
is a new error type, following the naming pattern ofFromBytesWithNulError
already existing forCStr::new
.This type, defined as:
It is inspired from the
FromUtf8Error
type (havingas_bytes
andinto_bytes
method) that allows recuperating the input when conversion failed.The
fmt:Display
implementation for the type uses the same text as theFromBytesWithNulError
, without using the deprecateddescription
method of theError
trait.Unresolved Questions
CStr::from_bytes_with_nul
(and itsunchecked
version) seems to indicates that having an owned version would be logical.bytes
tovec
in the names (CStr::from_bytes_with_nul
->CString::from_vec_with_nul
andCStr::from_bytes_with_nul_unchecked
->CString::from_vec_with_nul_unchecked
).Vec<u8>
but I seeCString::new
usesInto<Vec<u8>>
, should I use that too ?Implementation history
PR #73139 implements this at the moment, in a
unstable
form, with documentation and doc tests.PR #89292 by @CleanCut proposes to stabilize this 🥳
Edit: this being the first time I write a tracking issue, please do not hesitate to tell me if there is something to fix.
The text was updated successfully, but these errors were encountered: