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

Create Rc/Arc directly from mut slice #128885

Closed
eduardosm opened this issue Aug 9, 2024 · 2 comments
Closed

Create Rc/Arc directly from mut slice #128885

eduardosm opened this issue Aug 9, 2024 · 2 comments
Labels
C-feature-request Category: A feature request, i.e: not implemented / a PR. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.

Comments

@eduardosm
Copy link
Contributor

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
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Aug 9, 2024
@jieyouxu jieyouxu added T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. C-feature-request Category: A feature request, i.e: not implemented / a PR. labels Aug 10, 2024
@jieyouxu
Copy link
Member

This will need a T-libs-api API Change Proposal (ACP).

@jieyouxu jieyouxu removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Aug 10, 2024
@eduardosm
Copy link
Contributor Author

Implemented in #129329.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-feature-request Category: A feature request, i.e: not implemented / a PR. 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

3 participants