Uh oh!
There was an error while loading. Please reload this page.
Implement Vec::splice and String::splice (RFC 1432) - #40434
Conversation
rust-highfive
commented
Mar 11, 2017
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
commented
Mar 11, 2017
I suppose I should duplicate the |
There was a problem hiding this comment.
This is contradicted by the comment under "Memory safety" below.
There was a problem hiding this comment.
How about
/// Note: The element range is removed when the Splice is dropped,
/// even if the iterator is not consumed until the end.
There was a problem hiding this comment.
Looks like this applies to Drain as well
durka
commented
Mar 11, 2017
via email
Yeah that sounds better! …On Fri, Mar 10, 2017 at 10:12 PM, Matt Ickstadt ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In src/libcollections/string.rs
<#40434 (comment)>:
> @@ -1382,6 +1382,71 @@ impl String {
}
}
+ /// Creates a splicing iterator that removes the specified range in the string,
+ /// replaces with the given string, and yields the removed chars.
+ /// The given string doesn’t need to be the same length as the range.
+ ///
+ /// Note: The element range is removed even if the iterator is not
+ /// consumed until the end.
Looks like this applies to Drain as well
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#40434 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAC3n6KJfprI9F5n14S7h1x_qaNK6TbXks5rkhEPgaJpZM4MaD4H>
.
|
durka
commented
Mar 11, 2017
via email
Looks like Drain removes the range and tail right away, and moves the tail
back at drop. So if you leak it, the tail doesn't come back. …On Fri, Mar 10, 2017 at 10:20 PM, Alex Burka ***@***.***> wrote:
Yeah that sounds better!
On Fri, Mar 10, 2017 at 10:12 PM, Matt Ickstadt ***@***.***>
wrote:
> ***@***.**** commented on this pull request.
> ------------------------------
>
> In src/libcollections/string.rs
> <#40434 (comment)>:
>
> > @@ -1382,6 +1382,71 @@ impl String {
> }
> }
>
> + /// Creates a splicing iterator that removes the specified range in the string,
> + /// replaces with the given string, and yields the removed chars.
> + /// The given string doesn’t need to be the same length as the range.
> + ///
> + /// Note: The element range is removed even if the iterator is not
> + /// consumed until the end.
>
> Looks like this applies to Drain as well
>
> —
> You are receiving this because you commented.
> Reply to this email directly, view it on GitHub
> <#40434 (comment)>, or mute
> the thread
> <https://github.com/notifications/unsubscribe-auth/AAC3n6KJfprI9F5n14S7h1x_qaNK6TbXks5rkhEPgaJpZM4MaD4H>
> .
>
|
SimonSapin
commented
Mar 11, 2017
Thank you for picking this up! |
mattico
commented
Mar 19, 2017
Let's get this landed once the beta-madness settles down 😉. |
mattico
commented
Mar 28, 2017
(Feel free to reassign, I just know you're around) |
alexcrichton
commented
Apr 1, 2017
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
commented
Apr 1, 2017
No problem, @alexcrichton. This RFC has waited a year, what's another week or so 😉. |
alexcrichton
left a comment
There was a problem hiding this comment.
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+
There was a problem hiding this comment.
Would it be possible for this to use Vec::splice?
There was a problem hiding this comment.
Do you mean using the Vec implementation for String in general, or using Vec::splice() in the string splice drop impl?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
I'll look into it after I rebase
bors
commented
Apr 6, 2017
☔ The latest upstream changes (presumably #41102) made this pull request unmergeable. Please resolve the merge conflicts. |
50cfe26 to
9878aa0Comparemattico
commented
Apr 10, 2017
I broke something during rebase, I'll ping you once I've fixed it. |
alexcrichton
commented
Apr 10, 2017
@mattico ok just ping me whenever it's green and I'll take a final pass before r+ |
mattico
commented
Apr 10, 2017
I found these comments interesting re: sharing drop impl https://github.com/rust-lang/rust/pull/32355/files#r57401834 |
mattico
commented
Apr 10, 2017
Note to self: add forget() test: https://github.com/rust-lang/rust/pull/32355/files#r57402156 |
alexcrichton
commented
Apr 10, 2017
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? |
carols10cents
commented
Apr 17, 2017
Hi @mattico! Friendly ping to keep this on your radar! |
mattico
commented
Apr 17, 2017
Haven't forgotten about this, just haven't had much time. Will try to get back to this this week sometime. |
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
mattico
commented
Apr 24, 2017
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
commented
Apr 24, 2017
These new tests pass locally so it should be safe to r+ |
alexcrichton
commented
Apr 24, 2017
@bors: r+ Thanks! |
bors
commented
Apr 24, 2017
📌 Commit feae5a0 has been approved by |
bors
commented
Apr 24, 2017
⌛ Testing commit feae5a0 with merge 05a2d62... |
bors
commented
Apr 24, 2017
💔 Test failed - status-travis |
frewsxcv
commented
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
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
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
alexcrichton
commented
Apr 25, 2017
@bors: retry |
bors
commented
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
commented
Apr 25, 2017
☀️ Test successful - status-appveyor, status-travis |
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