about summary refs log tree commit diff
path: root/src/liballoc/string.rs
diff options
context:
space:
mode:
authorCorey Farwell <coreyf@rwell.org>2017-09-14 22:32:38 -0400
committerGitHub <noreply@github.com>2017-09-14 22:32:38 -0400
commitb4f6fba1d9b3acddc8c63e7ccdf857cfc0032aa2 (patch)
treedf0a63fc920931ab7b0f14f9d820d0bb28b842dd /src/liballoc/string.rs
parent1e2d6a804e518f4c96916401e11fce47bac489b7 (diff)
parentbc1a4c635703e08f0ee5830b389b2b804e82d76b (diff)
downloadrust-b4f6fba1d9b3acddc8c63e7ccdf857cfc0032aa2.tar.gz
rust-b4f6fba1d9b3acddc8c63e7ccdf857cfc0032aa2.zip
Rollup merge of #44453 - tommyip:doc_string_as_mut_str, r=frewsxcv
Add doc example to String::as_mut_str

Fixes #44429.
Diffstat (limited to 'src/liballoc/string.rs')
-rw-r--r--src/liballoc/string.rs17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/liballoc/string.rs b/src/liballoc/string.rs
index 1708f3e3987..8cecc59127e 100644
--- a/src/liballoc/string.rs
+++ b/src/liballoc/string.rs
@@ -759,7 +759,22 @@ impl String {
         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 {