diff options
| author | bors <bors@rust-lang.org> | 2017-09-15 04:22:45 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2017-09-15 04:22:45 +0000 |
| commit | d86a7f7a78e96bd28468e165c2b223b3b6ecc11d (patch) | |
| tree | 78839e9a358a6781af8c1dd0a21b3f9503382b3a /src/liballoc/string.rs | |
| parent | 2d288a5ae5e2e72b1c40611db80f94bbec75639b (diff) | |
| parent | 68e0f28304249a4f2db6b177b3be156ba4774a92 (diff) | |
| download | rust-d86a7f7a78e96bd28468e165c2b223b3b6ecc11d.tar.gz rust-d86a7f7a78e96bd28468e165c2b223b3b6ecc11d.zip | |
Auto merge of #44585 - frewsxcv:rollup, r=frewsxcv
Rollup of 23 pull requests - Successful merges: #44131, #44254, #44368, #44374, #44378, #44388, #44430, #44450, #44453, #44472, #44476, #44477, #44485, #44497, #44521, #44534, #44536, #44541, #44552, #44559, #44563, #44569, #44572 - Failed merges:
Diffstat (limited to 'src/liballoc/string.rs')
| -rw-r--r-- | src/liballoc/string.rs | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/src/liballoc/string.rs b/src/liballoc/string.rs index 1708f3e3987..46b96df1eab 100644 --- a/src/liballoc/string.rs +++ b/src/liballoc/string.rs @@ -622,6 +622,13 @@ impl String { /// Decode a UTF-16 encoded slice `v` into a `String`, replacing /// invalid data with the replacement character (U+FFFD). /// + /// Unlike [`from_utf8_lossy`] which returns a [`Cow<'a, str>`], + /// `from_utf16_lossy` returns a `String` since the UTF-16 to UTF-8 + /// conversion requires a memory allocation. + /// + /// [`from_utf8_lossy`]: #method.from_utf8_lossy + /// [`Cow<'a, str>`]: ../borrow/enum.Cow.html + /// /// # Examples /// /// Basic usage: @@ -759,7 +766,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 { |
