Skip to content

Commit 41b0761

Browse files
authored
Rollup merge of rust-lang#44453 - tommyip:doc_string_as_mut_str, r=frewsxcv
Add doc example to String::as_mut_str Fixes rust-lang#44429.
2 parents 310d771 + bc1a4c6 commit 41b0761

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

src/liballoc/string.rs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -759,7 +759,22 @@ impl String {
759759
self
760760
}
761761

762-
/// Extracts a string slice containing the entire string.
762+
/// Converts a `String` into a mutable string slice.
763+
///
764+
/// # Examples
765+
///
766+
/// Basic usage:
767+
///
768+
/// ```
769+
/// use std::ascii::AsciiExt;
770+
///
771+
/// let mut s = String::from("foobar");
772+
/// let s_mut_str = s.as_mut_str();
773+
///
774+
/// s_mut_str.make_ascii_uppercase();
775+
///
776+
/// assert_eq!("FOOBAR", s_mut_str);
777+
/// ```
763778
#[inline]
764779
#[stable(feature = "string_as_str", since = "1.7.0")]
765780
pub fn as_mut_str(&mut self) -> &mut str {

0 commit comments

Comments
 (0)