-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
std: Change String::truncate to panic less #32977
Conversation
r? @aturon (rust_highfive has picked a reviewer for you, use r? to override) |
r? @brson |
@bors r+ |
📌 Commit 41861ed has been approved by |
@alexcrichton: You need to update |
The `Vec::truncate` method does not panic if the length argument is greater than the vector's current length, but `String::truncate` will indeed panic. This semantic difference can be a bit jarring (e.g. rust-lang#32717), and after some discussion the libs team concluded that although this can technically be a breaking change it is almost undoubtedly not so in practice. This commit changes the semantics of `String::truncate` to be a noop if `new_len` is greater than the length of the current string. Closes rust-lang#32717
41861ed
to
ae79ce3
Compare
⌛ Testing commit ae79ce3 with merge 20dafb0... |
💔 Test failed - auto-win-gnu-32-opt-rustbuild |
@bors: retry On Sat, Apr 16, 2016 at 2:06 AM, bors notifications@github.com wrote:
|
⌛ Testing commit ae79ce3 with merge b5de94f... |
std: Change String::truncate to panic less The `Vec::truncate` method does not panic if the length argument is greater than the vector's current length, but `String::truncate` will indeed panic. This semantic difference can be a bit jarring (e.g. #32717), and after some discussion the libs team concluded that although this can technically be a breaking change it is almost undoubtedly not so in practice. This commit changes the semantics of `String::truncate` to be a noop if `new_len` is greater than the length of the current string. Closes #32717
The
Vec::truncate
method does not panic if the length argument is greater thanthe vector's current length, but
String::truncate
will indeed panic. Thissemantic difference can be a bit jarring (e.g. #32717), and after some
discussion the libs team concluded that although this can technically be a
breaking change it is almost undoubtedly not so in practice.
This commit changes the semantics of
String::truncate
to be a noop ifnew_len
is greater than the length of the current string.Closes #32717