You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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.
Reacted by lcnr, Skyler Ross, Justin Pombrio, Laine Taffin Altman, Brandon H. Gomes, Cyborus04, Martin HabovΕ‘tiak, zachs18 and Anton Dyudin
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.
Activity
programmerjake commentedon Apr 30, 2020
seems to me that it would be better to instead have the function convert from
Box<T>toBox<[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 toBox<[T]>if needed.m-ou-se commentedon Oct 27, 2021
Can this be a
Fromimpl instead?elichai commentedon Oct 28, 2021
@m-ou-se Yes! the only reason this isn't a
Fromimpl is becauseFromare insta-stable: #71421 (comment)elichai commentedon Mar 16, 2023
This will also be super useful for Rc/Arc
@m-ou-se Where/How can I discuss turning these into a
Fromimpl? (with the insta-stable implications)zachs18 commentedon Jul 21, 2024
Making this a
Fromimpl would conflict1 with existingFrom<Box<Local>> for Box<[Local]>impls, sinceBoxis#[fundamental]and thus treated like its pointee for coherence purposes in most cases. (Similarly,std::{array,slice}::from_{ref,mut}becomingFromimpls would be breaking.)I don't think adding
From<Rc<T>> for Rc<[T]>orfor Rc<[T; 1]>(orArc) would have the same issue, sinceRc/Arcare not#[fundamental].Also, we could add
alloc::array::from_boxed(_: Box<T>) -> Box<[T; 1]>andalloc::slice::from_boxed(_: Box<T>) -> Box<[T]>analogous tofrom_ref/from_mutinstead of or in addition to having associated fn(s) onBox.Footnotes
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. β©
safinaskar commentedon Feb 6, 2025
@rustbot label A-box
SleighPenguin22 commentedon Nov 20, 2026
Hi all, could I look at adjusting the documentation for this? it would be my first contribution. I posted about it on Zulip also!