]> git.lizzy.rs Git - rust.git/commitdiff
String::truncate doc: also fails if not a char boundary
authorSimon Sapin <simon.sapin@exyr.org>
Sun, 5 Oct 2014 11:15:59 +0000 (12:15 +0100)
committerSimon Sapin <simon.sapin@exyr.org>
Sun, 5 Oct 2014 11:15:59 +0000 (12:15 +0100)
src/libcollections/string.rs

index 2cc225f50bc3df136fcc727375ec50d01657f3fb..43fcdfae4d63568c3c164ba0b4002620e0c7c573 100644 (file)
@@ -613,7 +613,8 @@ pub unsafe fn as_mut_bytes<'a>(&'a mut self) -> &'a mut [u8] {
     ///
     /// # Failure
     ///
-    /// Fails if `len` > current length.
+    /// Fails if `new_len` > current length,
+    /// or if `new_len` is not a character boundary.
     ///
     /// # Example
     ///
@@ -624,9 +625,9 @@ pub unsafe fn as_mut_bytes<'a>(&'a mut self) -> &'a mut [u8] {
     /// ```
     #[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.