Skip to content
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 Box::into_boxed_slice #71582

Open
1 of 3 tasks
elichai opened this issue Apr 26, 2020 · 5 comments
Open
1 of 3 tasks

Tracking Issue for Box::into_boxed_slice #71582

elichai opened this issue Apr 26, 2020 · 5 comments
Labels
A-slice Area: `[T]` B-unstable Blocker: Implemented in the nightly compiler and unstable. C-tracking-issue Category: An issue tracking the progress of sth. like the implementation of an RFC Libs-Small Libs issues that are considered "small" or self-contained 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

@elichai
Copy link
Contributor

elichai commented Apr 26, 2020

This is a tracking issue for Box::into_boxed_slice.
The feature gate for the issue is #![feature(box_into_boxed_slice)].

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

@elichai elichai added the C-tracking-issue Category: An issue tracking the progress of sth. like the implementation of an RFC label Apr 26, 2020
@jonas-schievink jonas-schievink added B-unstable Blocker: Implemented in the nightly compiler and unstable. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. labels Apr 26, 2020
@programmerjake
Copy link
Member

seems to me that it would be better to instead have the function convert from Box<T> to Box<[T; 1]> since that's the minimal unsafe part, allowing the function to be more general, and since safe code can easily coerce the result to Box<[T]> if needed.

@KodrAus KodrAus added A-slice Area: `[T]` Libs-Small Libs issues that are considered "small" or self-contained Libs-Tracked Libs issues that are tracked on the team's project board. labels Jul 29, 2020
@m-ou-se
Copy link
Member

m-ou-se commented Oct 27, 2021

Can this be a From impl instead?

@elichai
Copy link
Contributor Author

elichai commented Oct 28, 2021

@m-ou-se Yes! the only reason this isn't a From impl is because From are insta-stable: #71421 (comment)

@elichai
Copy link
Contributor Author

elichai commented Mar 16, 2023

This will also be super useful for Rc/Arc
@m-ou-se Where/How can I discuss turning these into a From impl? (with the insta-stable implications)

@zachs18
Copy link
Contributor

zachs18 commented Jul 21, 2024

Making this a From impl would conflict1 with existing From<Box<Local>> for Box<[Local]> impls, since Box is #[fundamental] and thus treated like its pointee for coherence purposes in most cases. (Similarly, std::{array,slice}::from_{ref,mut} becoming From impls would be breaking.)
I don't think adding From<Rc<T>> for Rc<[T]> or for Rc<[T; 1]> (or Arc) would have the same issue, since Rc/Arc are not #[fundamental].

Also, we could add alloc::array::from_boxed(_: Box<T>) -> Box<[T; 1]> and alloc::slice::from_boxed(_: Box<T>) -> Box<[T]> analogous to from_ref/from_mut instead of or in addition to having associated fn(s) on Box.

Footnotes

  1. I suppose a crater run could be done to see if such implementations are common, but I think this would count under the "adding a fundamental trait impl is a major change" section of the API Evolution RFC and might not be allowed regardless.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-slice Area: `[T]` B-unstable Blocker: Implemented in the nightly compiler and unstable. C-tracking-issue Category: An issue tracking the progress of sth. like the implementation of an RFC Libs-Small Libs issues that are considered "small" or self-contained 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

No branches or pull requests

6 participants