-
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 slice_take
#62280
Comments
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
https://doc.rust-lang.org/nightly/std/ops/trait.OneSidedRange.html links to #69780 which is closed. Either it should be reopened (and some details filled in) or |
Can we implement Footnotes
|
Perhaps also rename |
Please, rename. Method Let me describe my actual production use case. First I read some data from file using |
FYI: #69780 is still being linked for |
I agree with @safinaskar that a different name for But changing the API to replace |
I'd love to see taking from a slice stabilized. But the introduction of
Meanwhile the The benefits of I propose the creation of a new implementation PR to remove cc @nox @cramertj @timvermeulen @ibraheemdev who worked on the previous implementation PR's. |
@safinaskar this conflict is indeed very unfortunate, however do note that there are workarounds. Notably you can:
See playground. |
@jongiddy I do find the current version with
I do not see the problem here. We have a lot of |
Perhaps Edit: Regarding the usefulness of |
I just discovered this API, after I once again reimplemented my own helper function for splitting off a prefix or suffix of a mutable slice :D Looking at the comments, my feedback:
Example:
|
|
There is precedent for |
Side note about full ranges being included in this API, but I think calling these "unbounded ranges" instead of "one-sided ranges" would make the APIs a bit clear. Even though the one-sided ranges have bounds, they still contain an unbounded side. |
I just stumbled over this feature after writing Has |
Should this also have an array version? e.g. fn take_first_chunk<'a, const N: usize>(self: &mut &'a Self) -> Option<&'a [T; N]>;
fn take_first_chunk_mut<'a, const N: usize>(self: &mut &'a mut Self) -> Option<&'a mut [T; N]>;
fn take_last_chunk<'a, const N: usize>(self: &mut &'a Self) -> Option<&'a [T; N]>;
fn take_last_chunk_mut<'a, const N: usize>(self: &mut &'a mut Self) -> Option<&'a mut [T; N]>; Would be very useful for reading and writing chunks of bytes from a slice. |
Feature gate:
#![feature(slice_take)]
Public API
Steps / History
take_...
functions to slices #62282take_...
functions to slices #77065Unresolved Questions
The text was updated successfully, but these errors were encountered: