Skip to content

Tracking issue for slice::from_ref and slice::from_ref_mut #45703

Closed
@whitequark

Description

@whitequark
Member

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];

Activity

added
B-unstableBlocker: Implemented in the nightly compiler and unstable.
C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFC
T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.
on Nov 1, 2017
SimonSapin

SimonSapin commented on Nov 15, 2017

@SimonSapin
Contributor

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

dtolnay commented on Nov 15, 2017

@dtolnay
Member

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

whitequark commented on Nov 15, 2017

@whitequark
MemberAuthor

Is it intended to be understood as (from_ref)mut or from(ref_mut)?

The latter. I think slice::from_mut is better here, too. I did not realize this in my initial PR.

steveklabnik

steveklabnik commented on Nov 15, 2017

@steveklabnik
Member

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

SimonSapin commented on Nov 15, 2017

@SimonSapin
Contributor

opt_slice(x) can be written as x.as_ref().map(ref_slice) which does not use unsafe (and is fairly standard Option manipulation code). So I think the need to include it is less pressing.

whitequark

whitequark commented on Nov 16, 2017

@whitequark
MemberAuthor
steveklabnik

steveklabnik commented on Nov 16, 2017

@steveklabnik
Member
SimonSapin

SimonSapin commented on Mar 17, 2018

@SimonSapin
Contributor

Looks good to me to stabilize.

@rfcbot fcp merge

rfcbot

rfcbot commented on Mar 17, 2018

@rfcbot
Collaborator

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.

added
proposed-final-comment-periodProposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off.
on Mar 17, 2018
dtolnay

dtolnay commented on Mar 17, 2018

@dtolnay
Member

Given that we have Option::get_ref and Option::get_mut which is not called get_ref_mut, I think here it should be from_ref and from_mut rather than from_ref_mut.

16 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    B-unstableBlocker: Implemented in the nightly compiler and unstable.C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCT-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.final-comment-periodIn the final comment period and will be merged soon unless new substantive objections are raised.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @steveklabnik@whitequark@alexcrichton@kennytm@SimonSapin

        Issue actions

          Tracking issue for `slice::from_ref` and `slice::from_ref_mut` · Issue #45703 · rust-lang/rust