]> git.lizzy.rs Git - rust.git/commit
Auto merge of #32977 - alexcrichton:ignore-panics, r=brson
authorbors <bors@rust-lang.org>
Sun, 17 Apr 2016 06:06:29 +0000 (23:06 -0700)
committerbors <bors@rust-lang.org>
Sun, 17 Apr 2016 06:06:29 +0000 (23:06 -0700)
commitb5de94fba9a137a1128448f4b703250e7e8ff975
tree57b28ae22fc683cd89d65477466375e335c09218
parent6892277cc030a9bc9931a644fffd3f420c41a6de
parentae79ce3f030db27aa7d35d1b22307fb4eba14f36
Auto merge of #32977 - alexcrichton:ignore-panics, r=brson

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