Skip to content

Commit 6722185

Browse files
committed
Indicate how to turn byte slices back into a string slice.
1 parent de4f1a1 commit 6722185

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/liballoc/str.rs

+9-2
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,10 @@ impl str {
273273
core_str::StrExt::is_char_boundary(self, index)
274274
}
275275

276-
/// Converts a string slice to a byte slice.
276+
/// Converts a string slice to a byte slice. To convert the byte slice back
277+
/// into a string slice, use the [`str::from_utf8`] function.
278+
///
279+
/// [`str::from_utf8`]: ./str/fn.from_utf8.html
277280
///
278281
/// # Examples
279282
///
@@ -289,7 +292,11 @@ impl str {
289292
core_str::StrExt::as_bytes(self)
290293
}
291294

292-
/// Converts a mutable string slice to a mutable byte slice.
295+
/// Converts a mutable string slice to a mutable byte slice. To convert the
296+
/// mutable byte slice back into a mutable string slice, use the
297+
/// [`str::from_utf8_mut`] function.
298+
///
299+
/// [`str::from_utf8_mut`]: ./str/fn.from_utf8_mut.html
293300
#[stable(feature = "str_mut_extras", since = "1.20.0")]
294301
#[inline(always)]
295302
pub unsafe fn as_bytes_mut(&mut self) -> &mut [u8] {

0 commit comments

Comments
 (0)