Skip to content

Commit

Permalink
Rollup merge of rust-lang#44449 - tommyip:doc_string_as_str, r=frewsxcv
Browse files Browse the repository at this point in the history
Add doc example to String::as_str

Fixes rust-lang#44428.
  • Loading branch information
frewsxcv authored Sep 9, 2017
2 parents 6482acd + 3e8fadc commit 8a6c9b5
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/liballoc/string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -743,6 +743,16 @@ impl String {
}

/// Extracts a string slice containing the entire string.
///
/// # Examples
///
/// Basic usage:
///
/// ```
/// let s = String::from("foo");
///
/// assert_eq!("foo", s.as_str());
/// ```
#[inline]
#[stable(feature = "string_as_str", since = "1.7.0")]
pub fn as_str(&self) -> &str {
Expand Down

0 comments on commit 8a6c9b5

Please sign in to comment.