Skip to content

String::truncate doc: also fails if not a char boundary #17794

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

Merged
merged 1 commit into from
Oct 6, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions src/libcollections/string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,8 @@ impl String {
///
/// # Failure
///
/// Fails if `len` > current length.
/// Fails if `new_len` > current length,
/// or if `new_len` is not a character boundary.
///
/// # Example
///
Expand All @@ -624,9 +625,9 @@ impl String {
/// ```
#[inline]
#[unstable = "the failure conventions for strings are under development"]
pub fn truncate(&mut self, len: uint) {
assert!(self.as_slice().is_char_boundary(len));
self.vec.truncate(len)
pub fn truncate(&mut self, new_len: uint) {
assert!(self.as_slice().is_char_boundary(new_len));
self.vec.truncate(new_len)
}

/// Appends a byte to this string buffer.
Expand Down