]> git.lizzy.rs Git - rust.git/blobdiff - src/liballoc/string.rs
Remove unchecked inline attribute, remove unused functions, make chache mod private...
[rust.git] / src / liballoc / string.rs
index d9927c642b2d8528cc012de950ace36fdbcdafa6..f7dff4c21f7c4343bdb79759ecf7a4755d38b720 100644 (file)
@@ -687,7 +687,7 @@ pub fn into_raw_parts(self) -> (*mut u8, usize, usize) {
     /// checked:
     ///
     /// * The memory at `ptr` needs to have been previously allocated by the
-    ///   same allocator the standard library uses.
+    ///   same allocator the standard library uses, with a required alignment of exactly 1.
     /// * `length` needs to be less than or equal to `capacity`.
     /// * `capacity` needs to be the correct value.
     ///
@@ -1402,7 +1402,9 @@ pub unsafe fn as_mut_vec(&mut self) -> &mut Vec<u8> {
         &mut self.vec
     }
 
-    /// Returns the length of this `String`, in bytes.
+    /// Returns the length of this `String`, in bytes, not [`char`]s or
+    /// graphemes. In other words, it may not be what a human considers the
+    /// length of the string.
     ///
     /// # Examples
     ///
@@ -1410,8 +1412,11 @@ pub unsafe fn as_mut_vec(&mut self) -> &mut Vec<u8> {
     ///
     /// ```
     /// let a = String::from("foo");
-    ///
     /// assert_eq!(a.len(), 3);
+    ///
+    /// let fancy_f = String::from("ƒoo");
+    /// assert_eq!(fancy_f.len(), 4);
+    /// assert_eq!(fancy_f.chars().count(), 3);
     /// ```
     #[inline]
     #[stable(feature = "rust1", since = "1.0.0")]