Skip to content

Commit 80401da

Browse files
committed
String::truncate doc: also fails if not a char boundary
1 parent dfbe9eb commit 80401da

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/libcollections/string.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -613,7 +613,8 @@ impl String {
613613
///
614614
/// # Failure
615615
///
616-
/// Fails if `len` > current length.
616+
/// Fails if `new_len` > current length,
617+
/// or if `new_len` is not a character boundary.
617618
///
618619
/// # Example
619620
///
@@ -624,9 +625,9 @@ impl String {
624625
/// ```
625626
#[inline]
626627
#[unstable = "the failure conventions for strings are under development"]
627-
pub fn truncate(&mut self, len: uint) {
628-
assert!(self.as_slice().is_char_boundary(len));
629-
self.vec.truncate(len)
628+
pub fn truncate(&mut self, new_len: uint) {
629+
assert!(self.as_slice().is_char_boundary(new_len));
630+
self.vec.truncate(new_len)
630631
}
631632

632633
/// Appends a byte to this string buffer.

0 commit comments

Comments
 (0)