diff options
| author | Tommy Ip <hkmp7tommy@gmail.com> | 2017-09-09 13:08:26 +0100 |
|---|---|---|
| committer | Tommy Ip <hkmp7tommy@gmail.com> | 2017-09-10 14:11:27 +0100 |
| commit | bc1a4c635703e08f0ee5830b389b2b804e82d76b (patch) | |
| tree | 002275dde12f2ce4fa4f8a7308480931b75dc459 /src/liballoc/string.rs | |
| parent | dee6d0f62e3b8bf8e58c4106f0f9bb54237c0807 (diff) | |
| download | rust-bc1a4c635703e08f0ee5830b389b2b804e82d76b.tar.gz rust-bc1a4c635703e08f0ee5830b389b2b804e82d76b.zip | |
Add doc example to String::as_mut_str
Fixes #44429.
Diffstat (limited to 'src/liballoc/string.rs')
| -rw-r--r-- | src/liballoc/string.rs | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/liballoc/string.rs b/src/liballoc/string.rs index ddb23b2ef37..9fef66f2c0a 100644 --- a/src/liballoc/string.rs +++ b/src/liballoc/string.rs @@ -749,7 +749,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 { |
