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

std: Change String::truncate to panic less #32977

Merged
merged 1 commit into from
Apr 17, 2016

Commits on Apr 15, 2016

  1. 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. 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
    alexcrichton committed Apr 15, 2016
    Configuration menu
    Copy the full SHA
    ae79ce3 View commit details
    Browse the repository at this point in the history