-
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 [T; N]::as_[mut_]slice
#76120
Add [T; N]::as_[mut_]slice
#76120
Conversation
These methods are like the ones on `std::array::FixedSizeArray` and in the crate `arraytools`.
(rust_highfive has picked a reviewer for you, use r? to override) |
I've wanted these methods several times. Thanks! |
r=me on implementation, since you are a libs team member :) It does feel a bit awkward to have these, since you get the same behavior just from coercion... but triggering coercion can be painful, and often means falling back on slicing, so this seems reasonable. |
Given that Vec has these, it makes sense that arrays might as well too. Hmm, it looks like this obviates |
Mhhhh... I'm not exactly sure what that means :D are you saying I can merge at my own convenience with
Probably? Though I would not include its removal in this PR. We might also want to wait a cycle or so before removing it. |
I mean that we normally need libs sign off on unstable API but you can self grant that and the impl looks good, so yes, just r=me when ready. |
From my side, this is ready. Let's merge it then, it's only unstable anyway. @bors r=Mark-Simulacrum |
📌 Commit d7afe2a has been approved by |
⌛ Testing commit d7afe2a with merge 8247a30061a79a7923718edf5a68d8eac473ee00... |
@bors retry yield |
Rollup of 12 pull requests Successful merges: - rust-lang#75150 (Add a note for Ipv4Addr::to_ipv6_compatible) - rust-lang#76120 (Add `[T; N]::as_[mut_]slice`) - rust-lang#76142 (Make all methods of `std::net::Ipv4Addr` const) - rust-lang#76164 (Link to slice pattern in array docs) - rust-lang#76167 (Replace MinGW library hack with heuristic controlling link mode) - rust-lang#76204 (Rename and expose LoopState as ControlFlow) - rust-lang#76238 (Move to intra-doc links for library/core/src/iter/traits/iterator.rs) - rust-lang#76242 (Read: adjust a FIXME reference) - rust-lang#76243 (Fix typos in vec try_reserve(_exact) docs) - rust-lang#76245 (inliner: Avoid query cycles when optimizing generators) - rust-lang#76255 (Update books) - rust-lang#76261 (Use intra-doc links in `core::marker`) Failed merges: r? @ghost
Broken in rust-lang#76120
Part of me trying to populate arrays with a couple of basic useful methods, like slices already have. The ability to add methods to arrays were added in #75212. Tracking issue: #76118
This adds:
These methods are like the ones on
std::array::FixedSizeArray
and in the cratearraytools
.