Skip to content

Tracking Issue for string_extend_from_within #103806

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
3 of 4 tasks
ghost opened this issue Oct 31, 2022 · 7 comments · Fixed by #137569
Closed
3 of 4 tasks

Tracking Issue for string_extend_from_within #103806

ghost opened this issue Oct 31, 2022 · 7 comments · Fixed by #137569
Labels
C-tracking-issue Category: An issue tracking the progress of sth. like the implementation of an RFC 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. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. to-announce Announce this issue on triage meeting
Milestone

Comments

@ghost
Copy link

ghost commented Oct 31, 2022

Feature gate: #![feature(string_extend_from_within)]

This is a tracking issue for the String::extend_from_within method.

This method is just like Vec::extend_from_within (which has been stable since 1.53.0).
Note that the original impl PR didn't create a tracking issue.

Public API

// in alloc::string

impl String {
    pub fn extend_from_within<R>(&mut self, src: R)
    where
        R: RangeBounds<usize>;
}

Steps / History

Unresolved Questions

  • None yet.

Footnotes

  1. https://std-dev-guide.rust-lang.org/feature-lifecycle/stabilization.html

@ghost ghost added C-tracking-issue Category: An issue tracking the progress of sth. like the implementation of an RFC T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. labels Oct 31, 2022
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this issue Nov 2, 2022
…cking-issue, r=Dylan-DPC

Add tracking issue for `string_extend_from_within`

Tracking issue: rust-lang#103806

The original PR didn't create a tracking issue.
@aDotInTheVoid
Copy link
Member

I think this is ready to be stabilised now. CC @rust-lang/libs-api.

Stabilisation report.

This mirrors the now stabilised (#84642) Vec::extend_from_within but on strings. Motivation is the same as that API on vecs, in that it’s hairy and hard to implement correctly, and that a specific API is needed for this for borrow-checker reasons.

@dtolnay
Copy link
Member

dtolnay commented Dec 13, 2024

Is there an example use case you could point out in real-world code? Being hairy to implement is not a motivation by itself.

@aDotInTheVoid
Copy link
Member

Sure here you go. This came about while helping with egraphs-good/egglog#496. The code we'd like to use it on is:

https://github.com/egraphs-good/egglog/blob/faeabbc762087fb0648e205f1479c36cbd7ec9a6/src/termdag.rs#L144-L192

We're trying to display a DAG as a string. If a node is a child of multiple parents, we want to use the already rendered string to represent it again. To do this, there's a HashMap<TermId, (usize, usize)> containing where in the output buffer a rendering of that term can be found. Then if we've seen the term before (via a different parent) we can extend_from_within the output, instead of rendering it.

At the moment, this works by using a Vec<u8> to store the output, than converting it to a String at the end. It'd be nicer if this API was also available on String, so the cost of conversion wasn't needed.

(I realize this isn't the simplest of use-cases, but it's the real world one that inspired me to ask to stabilize this)

@dtolnay
Copy link
Member

dtolnay commented Dec 16, 2024

Thanks, that is exactly what I was looking for.

@rfcbot fcp merge

@rfcbot
Copy link
Collaborator

rfcbot commented Dec 16, 2024

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. labels Dec 16, 2024
@rfcbot rfcbot added the final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. label Feb 11, 2025
@rfcbot
Copy link
Collaborator

rfcbot commented Feb 11, 2025

🔔 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 Feb 11, 2025
@rfcbot rfcbot added finished-final-comment-period The final comment period is finished for this PR / Issue. to-announce Announce this issue on triage meeting and removed final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. labels Feb 21, 2025
@rfcbot
Copy link
Collaborator

rfcbot commented Feb 21, 2025

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.

jieyouxu added a commit to jieyouxu/rust that referenced this issue Mar 4, 2025
workingjubilee added a commit to workingjubilee/rustc that referenced this issue Mar 5, 2025
@bors bors closed this as completed in 604d1ba Mar 5, 2025
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Mar 5, 2025
Rollup merge of rust-lang#137569 - aDotInTheVoid:for-iurii, r=ibraheemdev

Stabilize `string_extend_from_within`

FCP'd here: rust-lang#103806 (comment).

Closes  rust-lang#103806.
github-actions bot pushed a commit to rust-lang/rustc-dev-guide that referenced this issue Mar 6, 2025
Stabilize `string_extend_from_within`

FCP'd here: rust-lang/rust#103806 (comment).

Closes  #103806.
github-actions bot pushed a commit to rust-lang/miri that referenced this issue Mar 6, 2025
Stabilize `string_extend_from_within`

FCP'd here: rust-lang/rust#103806 (comment).

Closes  #103806.
lnicola pushed a commit to lnicola/rust-analyzer that referenced this issue Mar 10, 2025
Stabilize `string_extend_from_within`

FCP'd here: rust-lang/rust#103806 (comment).

Closes  #103806.
github-actions bot pushed a commit to model-checking/verify-rust-std that referenced this issue Mar 14, 2025
@cuviper cuviper added this to the 1.87.0 milestone Mar 21, 2025
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
C-tracking-issue Category: An issue tracking the progress of sth. like the implementation of an RFC 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. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. to-announce Announce this issue on triage meeting
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants