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

Tracking issue for String::insert_str #35553

Closed
murarth opened this issue Aug 9, 2016 · 8 comments
Closed

Tracking issue for String::insert_str #35553

murarth opened this issue Aug 9, 2016 · 8 comments
Labels
B-unstable Blocker: Implemented in the nightly compiler and unstable. final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.

Comments

@murarth
Copy link
Contributor

murarth commented Aug 9, 2016

Tracking issue for String::insert_str, introduced in #34771

@apasel422 apasel422 added the B-unstable Blocker: Implemented in the nightly compiler and unstable. label Aug 9, 2016
@apasel422
Copy link
Contributor

CC #35554.

@alexcrichton alexcrichton added the T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. label Aug 9, 2016
@tshepang
Copy link
Member

tshepang commented Nov 7, 2016

why is this not yet stabilised

@rhysd
Copy link
Contributor

rhysd commented Dec 27, 2016

I made a workaround for this until this API is stabilised.

pub fn insert(target: &mut String, index: usize, inserted: &str) {
    for c in inserted.chars().rev() {
        target.insert(index, c);
    }
}

@SimonSapin
Copy link
Contributor

@rhysd This work, but takes O(N × (M + N)) time where N = inserted.len() and M = target.len() - index. (This is because a single String::insert call takes O(M) time, since it needs to move the bytes in target after index to the right in order to make room for c.) But maybe that’s OK for you because N and M are small in your program.

String::insert_str uses unsafe code to only move bytes once, and so takes O(M + N) time.

@rhysd
Copy link
Contributor

rhysd commented Dec 28, 2016

@SimonSapin yeah, N is 4 and M is 10~20. Just a workaround for this API.

@alexcrichton
Copy link
Member

@rfcbot fcp merge

Seems like a consistent API and has baked for awhile!

@rfcbot
Copy link

rfcbot commented Dec 28, 2016

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

No concerns currently listed.

Once these reviewers reach consensus, 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.

@sfackler sfackler added the final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. label Jan 19, 2017
@rfcbot
Copy link

rfcbot commented Jan 23, 2017

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

psst @alexcrichton, I wasn't able to add the final-comment-period label, please do so.

alexcrichton added a commit to alexcrichton/rust that referenced this issue Jan 26, 2017
This commit applies the stabilization/deprecations of the 1.16.0 release, as
tracked by the rust-lang/rust issue tracker and the final-comment-period tag.

The following APIs were stabilized:

* `VecDeque::truncate`
* `VecDeque::resize`
* `String::insert_str`
* `Duration::checked_{add,sub,div,mul}`
* `str::replacen`
* `SocketAddr::is_ipv{4,6}`
* `IpAddr::is_ipv{4,6}`
* `str::repeat`
* `Vec::dedup_by`
* `Vec::dedup_by_key`
* `Result::unwrap_or_default`
* `<*const T>::wrapping_offset`
* `<*mut T>::wrapping_offset`
* `CommandExt::creation_flags` (on Windows)
* `File::set_permissions`
* `String::split_off`

The following APIs were deprecated

* `EnumSet` - replaced with other ecosystem abstractions, long since unstable

Closes rust-lang#27788
Closes rust-lang#35553
Closes rust-lang#35774
Closes rust-lang#36436
Closes rust-lang#36949
Closes rust-lang#37079
Closes rust-lang#37087
Closes rust-lang#37516
Closes rust-lang#37827
Closes rust-lang#37916
Closes rust-lang#37966
Closes rust-lang#38080
alexcrichton added a commit to alexcrichton/rust that referenced this issue Jan 28, 2017
std: Stabilize APIs for the 1.16.0 release

This commit applies the stabilization/deprecations of the 1.16.0 release, as
tracked by the rust-lang/rust issue tracker and the final-comment-period tag.

The following APIs were stabilized:

* `VecDeque::truncate`
* `VecDeque::resize`
* `String::insert_str`
* `Duration::checked_{add,sub,div,mul}`
* `str::replacen`
* `SocketAddr::is_ipv{4,6}`
* `IpAddr::is_ipv{4,6}`
* `str::repeat`
* `Vec::dedup_by`
* `Vec::dedup_by_key`
* `Result::unwrap_or_default`
* `<*const T>::wrapping_offset`
* `<*mut T>::wrapping_offset`
* `CommandExt::creation_flags` (on Windows)
* `File::set_permissions`
* `String::split_off`

The following APIs were deprecated

* `EnumSet` - replaced with other ecosystem abstractions, long since unstable

Closes rust-lang#27788
Closes rust-lang#35553
Closes rust-lang#35774
Closes rust-lang#36436
Closes rust-lang#36949
Closes rust-lang#37079
Closes rust-lang#37087
Closes rust-lang#37516
Closes rust-lang#37827
Closes rust-lang#37916
Closes rust-lang#37966
Closes rust-lang#38080
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
B-unstable Blocker: Implemented in the nightly compiler and unstable. final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. 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

8 participants