about summary refs log tree commit diff
diff options
context:
space:
mode:
authorCorey Farwell <coreyf@rwell.org>2017-08-04 23:08:29 -0400
committerCorey Farwell <coreyf@rwell.org>2017-08-05 08:27:25 -0400
commit6722185abdab8c5b83109a375e3fe14bd6aa8dc4 (patch)
tree2cb4e8d328f833b4e0ce0ce4376f266930aa81cc
parentde4f1a170f96f7e99f28dda534a7b76010499587 (diff)
downloadrust-6722185abdab8c5b83109a375e3fe14bd6aa8dc4.tar.gz
rust-6722185abdab8c5b83109a375e3fe14bd6aa8dc4.zip
Indicate how to turn byte slices back into a string slice.
-rw-r--r--src/liballoc/str.rs11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/liballoc/str.rs b/src/liballoc/str.rs
index bf375ca0c43..80317cd763b 100644
--- a/src/liballoc/str.rs
+++ b/src/liballoc/str.rs
@@ -273,7 +273,10 @@ impl str {
         core_str::StrExt::is_char_boundary(self, index)
     }
 
-    /// Converts a string slice to a byte slice.
+    /// Converts a string slice to a byte slice. To convert the byte slice back
+    /// into a string slice, use the [`str::from_utf8`] function.
+    ///
+    /// [`str::from_utf8`]: ./str/fn.from_utf8.html
     ///
     /// # Examples
     ///
@@ -289,7 +292,11 @@ impl str {
         core_str::StrExt::as_bytes(self)
     }
 
-    /// Converts a mutable string slice to a mutable byte slice.
+    /// Converts a mutable string slice to a mutable byte slice. To convert the
+    /// mutable byte slice back into a mutable string slice, use the
+    /// [`str::from_utf8_mut`] function.
+    ///
+    /// [`str::from_utf8_mut`]: ./str/fn.from_utf8_mut.html
     #[stable(feature = "str_mut_extras", since = "1.20.0")]
     #[inline(always)]
     pub unsafe fn as_bytes_mut(&mut self) -> &mut [u8] {