about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorSteven Allen <steven@stebalien.com>2017-02-16 22:49:46 -0800
committerSteven Allen <steven@stebalien.com>2017-02-16 22:49:46 -0800
commiteec9e988e18ff33a60dc7a9056bf2d4a35fd2a20 (patch)
tree7b65eb7e93cf3b73187c12d06ef341460a211605 /src
parent668864d9edd4f28d48005b57e5b177228cb974c5 (diff)
downloadrust-eec9e988e18ff33a60dc7a9056bf2d4a35fd2a20.tar.gz
rust-eec9e988e18ff33a60dc7a9056bf2d4a35fd2a20.zip
Fixup String::split_off documentation
1. Clarify that `String::split_off` returns one string and modifies self
   in-place. The documentation implied that it returns two new strings.

2. Make the documentation mirror `Vec::split_off`.
Diffstat (limited to 'src')
-rw-r--r--src/libcollections/string.rs18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/libcollections/string.rs b/src/libcollections/string.rs
index 4c82e2e2e7e..e92eb4ff7bd 100644
--- a/src/libcollections/string.rs
+++ b/src/libcollections/string.rs
@@ -1250,17 +1250,17 @@ impl String {
         self.len() == 0
     }
 
-    /// Divide one string into two at an index.
+    /// Splits the string into two at the given index.
     ///
-    /// The argument, `mid`, should be a byte offset from the start of the string. It must also
-    /// be on the boundary of a UTF-8 code point.
+    /// Returns a newly allocated `String`. `self` contains bytes `[0, at)`, and
+    /// the returned `String` contains bytes `[at, len)`. `at` must be on the
+    /// boundary of a UTF-8 code point.
     ///
-    /// The two strings returned go from the start of the string to `mid`, and from `mid` to the end
-    /// of the string.
+    /// Note that the capacity of `self` does not change.
     ///
     /// # Panics
     ///
-    /// Panics if `mid` is not on a `UTF-8` code point boundary, or if it is beyond the last
+    /// Panics if `at` is not on a `UTF-8` code point boundary, or if it is beyond the last
     /// code point of the string.
     ///
     /// # Examples
@@ -1275,9 +1275,9 @@ impl String {
     /// ```
     #[inline]
     #[stable(feature = "string_split_off", since = "1.16.0")]
-    pub fn split_off(&mut self, mid: usize) -> String {
-        assert!(self.is_char_boundary(mid));
-        let other = self.vec.split_off(mid);
+    pub fn split_off(&mut self, at: usize) -> String {
+        assert!(self.is_char_boundary(at));
+        let other = self.vec.split_off(at);
         unsafe { String::from_utf8_unchecked(other) }
     }