Rollup merge of #44477 - napen123:master, r=frewsxcv

Add doc examples to str::from_utf8_unchecked_mut

Fixes #44461
This commit is contained in:
Corey Farwell 2017-09-14 22:32:42 -04:00 committed by GitHub
commit 592cafeb3d

View File

@ -413,6 +413,19 @@ pub unsafe fn from_utf8_unchecked(v: &[u8]) -> &str {
/// See the immutable version, [`from_utf8_unchecked()`][fromutf8], for more information.
///
/// [fromutf8]: fn.from_utf8_unchecked.html
///
/// # Examples
///
/// Basic usage:
///
/// ```
/// use std::str;
///
/// let mut heart = vec![240, 159, 146, 150];
/// let heart = unsafe { str::from_utf8_unchecked_mut(&mut heart) };
///
/// assert_eq!("💖", heart);
/// ```
#[inline]
#[stable(feature = "str_mut_extras", since = "1.20.0")]
pub unsafe fn from_utf8_unchecked_mut(v: &mut [u8]) -> &mut str {