1
Fork 0

Rollup merge of #44453 - tommyip:doc_string_as_mut_str, r=frewsxcv

Add doc example to String::as_mut_str

Fixes #44429.
This commit is contained in:
Corey Farwell 2017-09-14 22:32:38 -04:00 committed by GitHub
commit b4f6fba1d9

View file

@ -759,7 +759,22 @@ impl String {
self self
} }
/// Extracts a string slice containing the entire string. /// Converts a `String` into a mutable string slice.
///
/// # Examples
///
/// Basic usage:
///
/// ```
/// use std::ascii::AsciiExt;
///
/// let mut s = String::from("foobar");
/// let s_mut_str = s.as_mut_str();
///
/// s_mut_str.make_ascii_uppercase();
///
/// assert_eq!("FOOBAR", s_mut_str);
/// ```
#[inline] #[inline]
#[stable(feature = "string_as_str", since = "1.7.0")] #[stable(feature = "string_as_str", since = "1.7.0")]
pub fn as_mut_str(&mut self) -> &mut str { pub fn as_mut_str(&mut self) -> &mut str {