Skip to content

Commit

Permalink
Rollup merge of rust-lang#44477 - napen123:master, r=frewsxcv
Browse files Browse the repository at this point in the history
Add doc examples to str::from_utf8_unchecked_mut

Fixes rust-lang#44461
  • Loading branch information
GuillaumeGomez authored Sep 13, 2017
2 parents d318148 + 8adf50d commit a7183cf
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/libcore/str/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit a7183cf

Please sign in to comment.