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

Implement str to [u8] conversion for refcounted containers #96078

Merged
merged 2 commits into from
May 1, 2022
Merged

Implement str to [u8] conversion for refcounted containers #96078

merged 2 commits into from
May 1, 2022

Conversation

udoprog
Copy link
Contributor

@udoprog udoprog commented Apr 15, 2022

This seems motivated to complete the APIs for shared containers since we already have similar allocation-free conversions for strings like From<Box<[u8]>> for Box<str>.

Insta-stable since it's a new trait impl?

@rustbot rustbot added the T-libs Relevant to the library team, which will review and decide on the PR/issue. label Apr 15, 2022
@rust-highfive
Copy link
Collaborator

Hey! It looks like you've submitted a new PR for the library teams!

If this PR contains changes to any rust-lang/rust public library APIs then please comment with r? rust-lang/libs-api @rustbot label +T-libs-api to request review from a libs-api team reviewer. If you're unsure where your change falls no worries, just leave it as is and the reviewer will take a look and make a decision to forward on if necessary.

Examples of T-libs-api changes:

  • a stabilization of a library feature
  • introducing new or changes existing unstable library APIs
  • changes to public documentation in ways that create new stability guarantees

@rust-highfive
Copy link
Collaborator

r? @thomcc

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Apr 15, 2022
@thomcc
Copy link
Member

thomcc commented Apr 15, 2022

The implementation seems fine and I'm not opposed, but

r? rust-lang/libs-api @rustbot label +T-libs-api

@rustbot rustbot added the T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. label Apr 15, 2022
@rust-highfive rust-highfive assigned m-ou-se and unassigned thomcc Apr 15, 2022
@dtolnay dtolnay added needs-fcp This change is insta-stable, so needs a completed FCP to proceed. and removed T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Apr 15, 2022
@dtolnay
Copy link
Member

dtolnay commented Apr 15, 2022

@rust-lang/libs-api:

impl From<Rc<str>> for Rc<[u8]> {}
impl From<Arc<str>> for Arc<[u8]> {}

This is the Rc and Arc version of what already exists for Box:

#[stable(feature = "boxed_str_conv", since = "1.19.0")]
impl<A: Allocator> From<Box<str, A>> for Box<[u8], A> {

@rfcbot fcp merge

@rfcbot
Copy link

rfcbot commented Apr 15, 2022

Team member @dtolnay has proposed to merge this. The next step is review by the rest of the tagged team members:

No concerns currently listed.

Once a majority of reviewers approve (and at most 2 approvals are outstanding), 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.

@rfcbot rfcbot added proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. labels Apr 15, 2022
@rfcbot
Copy link

rfcbot commented Apr 21, 2022

🔔 This is now entering its final comment period, as per the review above. 🔔

@rfcbot rfcbot removed the proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. label Apr 21, 2022
@rfcbot rfcbot added finished-final-comment-period The final comment period is finished for this PR / Issue. and removed final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. labels May 1, 2022
@rfcbot
Copy link

rfcbot commented May 1, 2022

The final comment period, with a disposition to merge, as per the review above, is now complete.

As the automated representative of the governance process, I would like to thank the author for their work and everyone else who contributed.

This will be merged soon.

@rfcbot rfcbot added the to-announce Announce this issue on triage meeting label May 1, 2022
@dtolnay
Copy link
Member

dtolnay commented May 1, 2022

@bors r+

@bors
Copy link
Contributor

bors commented May 1, 2022

📌 Commit 100006b has been approved by dtolnay

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 1, 2022
@bors
Copy link
Contributor

bors commented May 1, 2022

⌛ Testing commit 100006b with merge f75d884...

@dtolnay dtolnay assigned dtolnay and unassigned m-ou-se May 1, 2022
@bors
Copy link
Contributor

bors commented May 1, 2022

☀️ Test successful - checks-actions
Approved by: dtolnay
Pushing f75d884 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label May 1, 2022
@bors bors merged commit f75d884 into rust-lang:master May 1, 2022
@rustbot rustbot added this to the 1.62.0 milestone May 1, 2022
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (f75d884): comparison url.

Summary: This benchmark run did not return any relevant results.

If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf.

@rustbot label: -perf-regression

@udoprog udoprog deleted the refcounted-str-to-u8 branch May 1, 2022 11:36
@petertodd
Copy link
Contributor

If we're going to allow this, we should also update the Safety notes for get_mut_unchecked to warn about the situation where a non-cloning conversion has been performed.

Also note how this conversion is safe only because both types are Freeze.

@apiraino apiraino removed the to-announce Announce this issue on triage meeting label May 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. finished-final-comment-period The final comment period is finished for this PR / Issue. merged-by-bors This PR was explicitly merged by bors. needs-fcp This change is insta-stable, so needs a completed FCP to proceed. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.