-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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 CString::from_vec_until_nul #95160
Conversation
(rust-highfive has picked a reviewer for you, use r? to override) |
The biggest downside to sharing the error type is that the names obviously don't match:
I also find it odd that |
This comment has been minimized.
This comment has been minimized.
bd07e0c
to
d4c9367
Compare
(fixed doc-test typo) |
To allow extensibility of the internals, as unlikely as it is. There are functions on the type to access it IIRC |
I think the example on this issue is supposed to consume the buffer: (sorry for the minor nit, the & just jumped out to me as odd) |
Fixed, thanks. |
Ah, I missed that |
☔ The latest upstream changes (presumably #94079) made this pull request unmergeable. Please resolve the merge conflicts. |
d4c9367
to
6fd7e90
Compare
Apologies for accidentally closing this; I don't seem to be able to re-open it so I opened a new PR #96186 with the same content. |
@ericseppanen you need to force push back to d4c9367 to be able to reopen the PR. (I think GitHub does this to avoid having two simultaneous PRs open from the same branch.) |
I tried that but it didn't seem to do anything. |
I don't see a force push here after https://github.com/rust-lang/rust/compare/d4c93674974e8ef0adc9f36d6cd613c25e598c6d..6fd7e9010db6be7605241c39eab7c5078ee2d5bd. Did you remember to use |
@jyn514 I did force push the branch to many different hashes, including the one you mentioned. Github stopped updating the "force-pushed from X to Y" message after the first one; I don't know why. After trying it a bunch of times I gave up and opened a new PR. I have updated the tracking issue to point to the new PR. |
This adds a fn that converts a
Vec
into aCString
, without requiring the nul byte to be at the end of the Vec. It is intended for the case when an FFI function call wrote a string of unknown length, whichfrom_vec_with_nul
doesn't handle easily.For example,
This is a companion to
CStr::from_bytes_until_nul
(#94984) , and shares the feature gate:cstr_from_bytes_until_nul
(tracking issue #95027).Unresolved questions:
I couldn't decide whether this fn should use its own unique error type, or whether it should share the error type with
from_vec_with_nul
. In this version I reused the existing error type, but I'm happy to change if that's the better choice.