Skip to content

Create Rc/Arc directly from mut slice #128885

Closed
@eduardosm

Description

@eduardosm

Right now, we have

impl From<&CStr> for Rc<CStr>
impl From<&OsStr> for Rc<OsStr>
impl From<&Path> for Rc<Path>
impl From<&str> for Rc<str>

and their Arc counterparts.

Even though a mut slice can be coerced into a non-mut one, I think it would be useful to have versions that can directly take &mut _.

For example, to be able to do something like:

let s: Rc<str> = chr.encode_utf8(&mut [0; 4]).into(); // the trait bound `Rc<str>: From<&mut str>` is not satisfied

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-feature-requestCategory: A feature request, i.e: not implemented / a PR.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions