Repository navigation
Tracking Issue for array_methods #76118
Description
This is a tracking issue for a couple of basic methods on arrays. The feature gate for the issue is #![feature(array_methods)]. Currently, this includes the following methods:
as_slice,as_mut_sliceAdd[T; N]::as_[mut_]slice#76120each_ref,each_mutAdd[T; N]::each_refand[T; N]::each_mut#75490
Note: these methods were all collected under the same array_methods feature name as I suspect many (often small) methods to be added to array in the near future. Creating a new feature and tracking issue for each seems overkill. We can still split off some methods into dedicated features later, if required.
About tracking issues
Tracking issues are used to record the overall progress of implementation.
They are also uses as hubs connecting to other relevant issues, e.g., bugs or open design questions.
A tracking issue is however not meant for large scale discussion, questions, or bug reports about a feature.
Instead, open a dedicated issue for the specific matter and add the relevant feature gate label.
Steps
- Decide what set of methods to stabilize in the first round
- Change feature names of all methods that are not yet stabilized to something specific
- Adjust documentation (see instructions on rustc-dev-guide)
- Stabilization PR (see instructions on rustc-dev-guide)
Unresolved Questions
- Use the names
each_refandeach_mutor change it to something else? Alternatives:each_as_ref/each_as_mut,as_refs/as_mut_refs. See PR Add[T; N]::each_refand[T; N]::each_mut#75490 for the name discussion.
Activity
LukasKalbertodt commentedon Aug 30, 2020
Just for the protocol, I plan to add the following methods in the near future:
cloned,copiedandunzip: blocked by figuring out how we best add additional impl blocks for arrays (e.g.[&T; N] where T: Clone)already added in Added [T; N]::zip() #79451zip: waiting for addarray::FillErrorsimilar toarray::IntoIter#75717 or Add 'core::array::from_fn' and 'core::array::try_from_fn' #75644 to get merged; otherwise this method would add duplicate code(discussions about the usefulness of those method should be had in the dedicated PR threads and not here)
Rollup merge of rust-lang#76120 - LukasKalbertodt:add-as-slice-method…
usbalbin commentedon Nov 29, 2020
@LukasKalbertodt I have opened PR #79451 for
zip, saw your comment just now.rossmacarthur commentedon May 11, 2021
With regards to stabilization I think
as_slice,as_mut_slicecould be stabilized first.I think they are much more useful than the others in this tracking issue. These are already common methods for existing data types so it's not a new API.
I sometimes find myself running into cases where
Derefcoercion doesn't work and I need this. Currently I'm using&arr[..]which doesn't really communicate well why it is needed.For example
LukasKalbertodt commentedon Jun 23, 2021
I agree with @rossmacarthur and would like to propose stabilizing
as_sliceandas_mut_slice. These methods exist on many other types throughoutstd(e.g.Vec) and I can't think of a reason to wait with stabilization. I can't see how the name or semantics would still change. And I'm pretty sure we want those methods.jhpratt commentedon Aug 26, 2021
Partial stabilization is up: #88353
21 remaining items
pravic commentedon Oct 20, 2023
Any news about this?
rfcbot commentedon Jan 16, 2024
🔔 This is now entering its final comment period, as per the review above. 🔔
rfcbot commentedon Jan 26, 2024
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.
Rollup merge of rust-lang#103522 - Dylan-DPC:76118/array-methods-stab…
Rollup merge of rust-lang#103522 - Dylan-DPC:76118/array-methods-stab…
Unrolled build for rust-lang#103522
Less unsafe with array_methods