Skip to content

Tracking issue for array::from_ref and array::from_mut #77101

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
1 of 3 tasks
Tracked by #16
lcnr opened this issue Sep 23, 2020 · 10 comments · Fixed by #84105
Closed
1 of 3 tasks
Tracked by #16

Tracking issue for array::from_ref and array::from_mut #77101

lcnr opened this issue Sep 23, 2020 · 10 comments · Fixed by #84105
Labels
A-slice Area: `[T]` C-tracking-issue Category: An issue tracking the progress of sth. like the implementation of an RFC disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. finished-final-comment-period The final comment period is finished for this PR / Issue. Libs-Tracked Libs issues that are tracked on the team's project board. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.

Comments

@lcnr
Copy link
Contributor

lcnr commented Sep 23, 2020

Tracking issue for feature(array_from_ref) which adds the following methods

// std::array
pub fn from_ref<T>(s: &T) -> &[T; 1];
pub fn from_mut<T>(s: &mut T) -> &mut [T; 1];

Steps / History

@lcnr lcnr added the C-tracking-issue Category: An issue tracking the progress of sth. like the implementation of an RFC label Sep 23, 2020
@jonas-schievink jonas-schievink added the T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. label Sep 23, 2020
@KodrAus KodrAus added the Libs-Tracked Libs issues that are tracked on the team's project board. label Nov 6, 2020
@KodrAus KodrAus added the A-slice Area: `[T]` label Jan 6, 2021
@WaffleLapkin
Copy link
Member

WaffleLapkin commented Jan 17, 2021

Why is the mut version name differs from the slice variant? (from_ref_mut vs from_mut) Nvm, it's a typo in the issue description, the actual method is named from_mut.

What is blocking stabilization, it seems like there aren't any open questions/controversies. Shall I make a stabilization PR?

@m-ou-se
Copy link
Member

m-ou-se commented Apr 12, 2021

@rfcbot merge

@rfcbot
Copy link
Collaborator

rfcbot commented Apr 12, 2021

Team member @m-ou-se has proposed to merge this. The next step is review by the rest of the tagged team members:

No concerns currently listed.

Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up!

See this document for info about what commands tagged team members can give me.

@rfcbot rfcbot added proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. labels Apr 12, 2021
@rfcbot
Copy link
Collaborator

rfcbot commented Apr 12, 2021

🔔 This is now entering its final comment period, as per the review above. 🔔

@rfcbot rfcbot removed the proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. label Apr 12, 2021
@rfcbot rfcbot added finished-final-comment-period The final comment period is finished for this PR / Issue. and removed final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. labels Apr 22, 2021
@rfcbot
Copy link
Collaborator

rfcbot commented Apr 22, 2021

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.

The RFC will be merged soon.

@rfcbot rfcbot added the to-announce Announce this issue on triage meeting label Apr 22, 2021
JohnTitor added a commit to JohnTitor/rust that referenced this issue Apr 24, 2021
…ef, r=m-ou-se

stabilize `core::array::{from_ref,from_mut}` in `1.53.0`

I didn't get any response in rust-lang#77101 (comment), so I figured out I can try opening stabilization pr.

---

This PR stabilizes following functions:
```rust
// core::array
pub fn from_ref<T>(s: &T) -> &[T; 1];
pub fn from_mut<T>(s: &mut T) -> &mut [T; 1];
```

Functions are similar to already stabilized `core::slice::{`[`from_ref`](https://doc.rust-lang.org/std/slice/fn.from_ref.html),[`from_mut`](https://doc.rust-lang.org/std/slice/fn.from_mut.html)`}` and were unstable without any problems/questions for a while now.

---

resolves rust-lang#77101

`@rustbot` modify labels: +T-libs
@bors bors closed this as completed in 46b67ab Apr 24, 2021
@apiraino apiraino removed the to-announce Announce this issue on triage meeting label Apr 29, 2021
@oconnor663
Copy link
Contributor

Has anyone proposed to stabilize these? Could I just open a PR to start that? :)

@WaffleLapkin
Copy link
Member

WaffleLapkin commented Jun 12, 2021

@oconnor663 I've proposed. In fact, they were already stabilized :)

#84105

@mzji
Copy link

mzji commented Aug 4, 2021

Since core::array::from_ref() and core::array::from_mut() has been stablized, could we now add impl<T> From<T> for [T; 1], impl<'a, T> From<&'a T> for &'a [T; 1] and impl<'a, T> From<&'a mut T> for &'a mut [T; 1] to libcore? These impls should be easy to implement (just one-liners) and ergonomic to use.

@jhpratt
Copy link
Member

jhpratt commented Aug 4, 2021

@mzji Feel free to create a pull request! I would imagine it would be accepted.

@zachs18
Copy link
Contributor

zachs18 commented Jul 21, 2024

[...] could we now add impl<T> From<T> for [T; 1], impl<'a, T> From<&'a T> for &'a [T; 1] and impl<'a, T> From<&'a mut T> for &'a mut [T; 1] to libcore? [...]

Adding From<T> for [T; 1] could conflict with downstream From<Local> for [Local; 1].
Similarly, since & and &mut are "fundamental" and behave like their pointee for coherence purposes, downstream impls of From<&'a Local> for &'a [Local; 1] etc are also currently allowed, such that adding impl<'a, T: 'a> From<&'a T> for &'a [T; 1] would also conflict.
Adding another x.into() candidate for x: &T also was pointed out as possibly being an issue for type inference
.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-slice Area: `[T]` C-tracking-issue Category: An issue tracking the progress of sth. like the implementation of an RFC disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. finished-final-comment-period The final comment period is finished for this PR / Issue. Libs-Tracked Libs issues that are tracked on the team's project board. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.