Skip to content

Commit bc1a4c6

Browse files
committed
Add doc example to String::as_mut_str
Fixes #44429.
1 parent dee6d0f commit bc1a4c6

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

src/liballoc/string.rs

+16-1
Original file line numberDiff line numberDiff line change
@@ -749,7 +749,22 @@ impl String {
749749
self
750750
}
751751

752-
/// Extracts a string slice containing the entire string.
752+
/// Converts a `String` into a mutable string slice.
753+
///
754+
/// # Examples
755+
///
756+
/// Basic usage:
757+
///
758+
/// ```
759+
/// use std::ascii::AsciiExt;
760+
///
761+
/// let mut s = String::from("foobar");
762+
/// let s_mut_str = s.as_mut_str();
763+
///
764+
/// s_mut_str.make_ascii_uppercase();
765+
///
766+
/// assert_eq!("FOOBAR", s_mut_str);
767+
/// ```
753768
#[inline]
754769
#[stable(feature = "string_as_str", since = "1.7.0")]
755770
pub fn as_mut_str(&mut self) -> &mut str {

0 commit comments

Comments
 (0)