Closed
Description
Tracking issue for feature from_ref
// std::slice
pub fn from_ref<T>(s: &T) -> &[T];
pub fn from_ref_mut<T>(s: &mut T) -> &mut [T];
- Implemented in Bring back slice::ref_slice as slice::from_ref. #45306
Metadata
Metadata
Assignees
Labels
Blocker: Implemented in the nightly compiler and unstable.Category: An issue tracking the progress of sth. like the implementation of an RFCRelevant to the library API team, which will review and decide on the PR/issue.In the final comment period and will be merged soon unless new substantive objections are raised.
Type
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
SimonSapin commentedon Nov 15, 2017
For archeology purpose: these were added to the standard library in 2014 419ac4a, then deprecated and moved to crates.io in 2015: #27774.
Now that we’ve decided to bring them back and are going through the process motions, can we start FCP to stabilize? CC @rust-lang/libs
dtolnay commentedon Nov 15, 2017
Is there anything else in the standard library that uses "ref_mut" to refer to
&mut T
? In RFC 199 we went the opposite way.Is it intended to be understood as (from_ref)_mut or from_(ref_mut)?
slice::from_mut
wouldn't seem accurate to me but is there a different naming that works better with_ref
and_mut
suffixes?whitequark commentedon Nov 15, 2017
The latter. I think
slice::from_mut
is better here, too. I did not realize this in my initial PR.steveklabnik commentedon Nov 15, 2017
I had left a brief comment in the original PR, but I didn't see anyone reply: my crate has two extra
Option
based versions as well, I don't know if we want to pull them in, or if my crate will still have some small use for those variants.SimonSapin commentedon Nov 15, 2017
opt_slice(x)
can be written asx.as_ref().map(ref_slice)
which does not useunsafe
(and is fairly standardOption
manipulation code). So I think the need to include it is less pressing.whitequark commentedon Nov 16, 2017
@steveklabnik I replied to you: #45306 (comment)
steveklabnik commentedon Nov 16, 2017
SimonSapin commentedon Mar 17, 2018
Looks good to me to stabilize.
@rfcbot fcp merge
rfcbot commentedon Mar 17, 2018
Team member @SimonSapin has proposed to merge this. The next step is review by the rest of the tagged teams:
No concerns currently listed.
Once a majority of reviewers approve (and none object), 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.
dtolnay commentedon Mar 17, 2018
Given that we have
Option::get_ref
andOption::get_mut
which is not calledget_ref_mut
, I think here it should befrom_ref
andfrom_mut
rather thanfrom_ref_mut
.16 remaining items