-
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
Add IoSlice::as_bytes #111277
Add IoSlice::as_bytes #111277
Conversation
r? @m-ou-se (rustbot has picked a reviewer for you, use r? to override) |
Hey! It looks like you've submitted a new PR for the library teams! If this PR contains changes to any Examples of
|
My own personal use case for this is an attempt to write my own |
This comment has been minimized.
This comment has been minimized.
Looks like the classic sorts of failures where an innate method is added and starts to take precedence over a trait method. Maybe |
How about |
@rustbot label +T-libs-api -T-libs |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
☔ The latest upstream changes (presumably #118154) made this pull request unmergeable. Please resolve the merge conflicts. |
@Lucretiel if you can address the CI failure and the conflicts, we can put this for review |
Taking a look now, thanks for your patience! |
cf9256f
to
6d3b2a1
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Doctests are failing because of the use of an unstable library feature (the one added in this PR); can someone walk me through how to fix? |
Add the |
Can we add the same for IoSliceMut? It looks like it has the same lifetime issue. |
I'm actually pretty sure we can't, though I'd be happy to be proven wrong. A function resembling |
In any case, this is (finally) ready to merge, just needs approval from someone. |
/// | ||
/// assert_eq!(io_slice.into_bytes(), b"def"); | ||
/// ``` | ||
#[unstable(feature = "io_slice_as_bytes", issue = "111277")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The issue number points to this PR; you should open a tracking issue and link it instead.
Also feature gate io_slice_as_bytes
-> io_slice_into_bytes
if that is the name.
Edit: io_slice_as_slice
with the below.
The ACP at rust-lang/libs-team#93 covers the change here. Two changes from this PR are that the accepted name was @rustbot author |
@Lucretiel any updates on this? thanks |
@Lucretiel |
…again, r=<try> Add as_slice/into_slice for IoSlice/IoSliceMut. ACP: rust-lang/libs-team#93 Based on a623c52 (CC `@mpdn)` and rust-lang#111277 (CC `@Lucretiel).` Closes: rust-lang#124659 Tracking Issue: TODO try-job: test-various try-job: dist-various-1 try-job: dist-various-2 r? `@ghost`
…again, r=<try> Add as_slice/into_slice for IoSlice/IoSliceMut. ACP: rust-lang/libs-team#93 Based on a623c52 (CC `@mpdn)` and rust-lang#111277 (CC `@Lucretiel).` Closes: rust-lang#124659 Tracking Issue: TODO try-job: test-various try-job: dist-various-1 try-job: dist-various-2 r? `@ghost`
This PR proposes to add
IoSlice::as_bytes
. WhileIoSlice
already hasDeref<Target=[u8]>
, this uses the lifetime of theIoSlice
itself, throwing away the larger'a
lifetime;as_bytes
allows for getting the original slice with the original lifetime.ACP: rust-lang/libs-team#93
Fixes #124659