Skip to content

Implement Vec::splice and String::splice (RFC 1432) - #40434

Merged
bors merged 6 commits into
rust-lang:masterfrom
mattico:splice-update
Apr 25, 2017
Merged

Implement Vec::splice and String::splice (RFC 1432)#40434
bors merged 6 commits into
rust-lang:masterfrom
mattico:splice-update

Conversation

@mattico

Copy link
Copy Markdown
Contributor

RFC: rust-lang/rfcs#1432, tracking issue: #32310
A rebase of #32355 with a few more tests.

Let me know if you have any ideas for more tests.

cc @SimonSapin

@rust-highfive

Copy link
Copy Markdown
Contributor

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @sfackler (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@mattico

Copy link
Copy Markdown
ContributorAuthor

I suppose I should duplicate the Vec tests in String and test the return value of splice()...

Comment threadsrc/libcollections/string.rs Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is contradicted by the comment under "Memory safety" below.

@matticomatticoMar 11, 2017

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about

/// Note: The element range is removed when the Splice is dropped,
/// even if the iterator is not consumed until the end.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this applies to Drain as well

Comment threadsrc/libcollections/vec.rs Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: this comma is unnecessary.

@durka

durka commented Mar 11, 2017 via email

Copy link
Copy Markdown
Contributor

@durka

durka commented Mar 11, 2017 via email

Copy link
Copy Markdown
Contributor

@SimonSapin

Copy link
Copy Markdown
Contributor

Thank you for picking this up!

@alexcrichtonalexcrichton added the T-libs-api [DEPRECATED; DO NOT USE] label Mar 14, 2017
@mattico

Copy link
Copy Markdown
ContributorAuthor

Let's get this landed once the beta-madness settles down 😉.

@matticomattico changed the title Implement Vec::splice and String::spliceImplement Vec::splice and String::splice (RFC 1432)Mar 22, 2017
@mattico

Copy link
Copy Markdown
ContributorAuthor

@bors r? @alexcrichton

(Feel free to reassign, I just know you're around)

@alexcrichton

Copy link
Copy Markdown
Member

sorry for being slow to review @mattico! I wanted to be sure to thank you for the PR, and just wanted to give you a heads up that I'll be traveling for the next week so it'll take some time to get around to reviewing this.

@mattico

Copy link
Copy Markdown
ContributorAuthor

No problem, @alexcrichton. This RFC has waited a year, what's another week or so 😉.

@alexcrichtonalexcrichton left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok got a chance to look this over and it looks fantastic to me, thanks @mattico!

Just one minor nit but other than that I'd be ready to r+

Comment threadsrc/libcollections/string.rs Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be possible for this to use Vec::splice?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean using the Vec implementation for String in general, or using Vec::splice() in the string splice drop impl?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general it may be pretty hard due to char decoding and whatnot, but here in drop it seems like it'd be a one-liner to call the vec impl for splicing I think, right?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll look into it after I rebase

@bors

bors commented Apr 6, 2017

Copy link
Copy Markdown
Collaborator

☔ The latest upstream changes (presumably #41102) made this pull request unmergeable. Please resolve the merge conflicts.

@mattico
matticoforce-pushed the splice-update branch 2 times, most recently from 50cfe26 to 9878aa0CompareApril 8, 2017 21:48
@mattico

Copy link
Copy Markdown
ContributorAuthor

I broke something during rebase, I'll ping you once I've fixed it.

@alexcrichton

Copy link
Copy Markdown
Member

@mattico ok just ping me whenever it's green and I'll take a final pass before r+

@mattico

Copy link
Copy Markdown
ContributorAuthor

I found these comments interesting re: sharing drop impl https://github.com/rust-lang/rust/pull/32355/files#r57401834

@mattico

Copy link
Copy Markdown
ContributorAuthor

Note to self: add forget() test: https://github.com/rust-lang/rust/pull/32355/files#r57402156

@alexcrichton

Copy link
Copy Markdown
Member

I think we don't need to worry about leaks in this case b/c we're already in a destructor and we're just dropping the splice value that we ourselves are creating, so I don't think there's leak issues? If the split iterator is leaked then I think the string is just safely truncated, right?

@Mark-SimulacrumMark-Simulacrum added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Apr 14, 2017
@carols10cents

Copy link
Copy Markdown
Member

Hi @mattico! Friendly ping to keep this on your radar!

@mattico

Copy link
Copy Markdown
ContributorAuthor

Haven't forgotten about this, just haven't had much time. Will try to get back to this this week sometime.

frewsxcv added a commit to frewsxcv/rust that referenced this pull request Apr 24, 2017
Implement Vec::splice and String::splice (RFC 1432)
RFC: rust-lang/rfcs#1432, tracking issue: rust-lang#32310
A rebase of rust-lang#32355 with a few more tests.
Let me know if you have any ideas for more tests.
cc @SimonSapin
@frewsxcvfrewsxcv mentioned this pull request Apr 24, 2017
@mattico

Copy link
Copy Markdown
ContributorAuthor

Oh whoops, I just pushed a forget() test, which codifies the current behavior. Technically for Vec it's unspecified what happens if you forget the Splice, but the test will at least make sure it doesn't change behavior accidentally.

@mattico

Copy link
Copy Markdown
ContributorAuthor

These new tests pass locally so it should be safe to r+

@alexcrichton

Copy link
Copy Markdown
Member

@bors: r+

Thanks!

@bors

bors commented Apr 24, 2017

Copy link
Copy Markdown
Collaborator

📌 Commit feae5a0 has been approved by alexcrichton

bors added a commit that referenced this pull request Apr 24, 2017
Rollup of 3 pull requests
- Successful merges: #40434, #41370, #41500
- Failed merges:
@bors

bors commented Apr 24, 2017

Copy link
Copy Markdown
Collaborator

⌛ Testing commit feae5a0 with merge 05a2d62...

@bors

bors commented Apr 24, 2017

Copy link
Copy Markdown
Collaborator

💔 Test failed - status-travis

@frewsxcv

Copy link
Copy Markdown
Contributor

@bors retry #40474

frewsxcv added a commit to frewsxcv/rust that referenced this pull request Apr 24, 2017
Implement Vec::splice and String::splice (RFC 1432)
RFC: rust-lang/rfcs#1432, tracking issue: rust-lang#32310
A rebase of rust-lang#32355 with a few more tests.
Let me know if you have any ideas for more tests.
cc @SimonSapin
@frewsxcvfrewsxcv mentioned this pull request Apr 24, 2017
frewsxcv added a commit to frewsxcv/rust that referenced this pull request Apr 24, 2017
Implement Vec::splice and String::splice (RFC 1432)
RFC: rust-lang/rfcs#1432, tracking issue: rust-lang#32310
A rebase of rust-lang#32355 with a few more tests.
Let me know if you have any ideas for more tests.
cc @SimonSapin
@frewsxcvfrewsxcv mentioned this pull request Apr 24, 2017
frewsxcv added a commit to frewsxcv/rust that referenced this pull request Apr 25, 2017
Implement Vec::splice and String::splice (RFC 1432)
RFC: rust-lang/rfcs#1432, tracking issue: rust-lang#32310
A rebase of rust-lang#32355 with a few more tests.
Let me know if you have any ideas for more tests.
cc @SimonSapin
@frewsxcvfrewsxcv mentioned this pull request Apr 25, 2017
@alexcrichton

Copy link
Copy Markdown
Member

@bors: retry

@arielb1arielb1 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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Apr 25, 2017
@bors

bors commented Apr 25, 2017

Copy link
Copy Markdown
Collaborator

⌛ Testing commit feae5a0 with merge c7e724a...

bors added a commit that referenced this pull request Apr 25, 2017
Implement Vec::splice and String::splice (RFC 1432)
RFC: rust-lang/rfcs#1432, tracking issue: #32310
A rebase of #32355 with a few more tests.
Let me know if you have any ideas for more tests.
cc @SimonSapin
@bors

bors commented Apr 25, 2017

Copy link
Copy Markdown
Collaborator

☀️ Test successful - status-appveyor, status-travis
Approved by: alexcrichton
Pushing c7e724a to master...

@bors
bors merged commit feae5a0 into rust-lang:masterApr 25, 2017
@mattico
mattico deleted the splice-update branch April 28, 2017 02:02
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-borsStatus: Waiting on bors to run and complete tests. Bors will change the label on completion.T-libs-api[DEPRECATED; DO NOT USE]

Projects

None yet

Development

Successfully merging this pull request may close these issues.

11 participants

@mattico@rust-highfive@durka@SimonSapin@alexcrichton@bors@carols10cents@frewsxcv@sfackler@arielb1@Mark-Simulacrum