Rollup merge of #44449 - tommyip:doc_string_as_str, r=frewsxcv

Add doc example to String::as_str

Fixes #44428.
This commit is contained in:
Guillaume Gomez 2017-09-10 14:03:28 +02:00 committed by GitHub
commit d3ef39f2af

View File

@ -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 {