]> git.lizzy.rs Git - rust.git/commitdiff
Add doc example to String::as_mut_str
authorTommy Ip <hkmp7tommy@gmail.com>
Sat, 9 Sep 2017 12:08:26 +0000 (13:08 +0100)
committerTommy Ip <hkmp7tommy@gmail.com>
Sun, 10 Sep 2017 13:11:27 +0000 (14:11 +0100)
Fixes #44429.

src/liballoc/string.rs

index ddb23b2ef37bf0898d72db4e213d96b4fa70e5a5..9fef66f2c0aaef08cdf501c8ad263f7db571cd22 100644 (file)
@@ -749,7 +749,22 @@ pub fn as_str(&self) -> &str {
         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]
     #[stable(feature = "string_as_str", since = "1.7.0")]
     pub fn as_mut_str(&mut self) -> &mut str {