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:
commit
d3ef39f2af
1 changed files with 10 additions and 0 deletions
|
@ -743,6 +743,16 @@ impl String {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Extracts a string slice containing the entire string.
|
/// Extracts a string slice containing the entire string.
|
||||||
|
///
|
||||||
|
/// # Examples
|
||||||
|
///
|
||||||
|
/// Basic usage:
|
||||||
|
///
|
||||||
|
/// ```
|
||||||
|
/// let s = String::from("foo");
|
||||||
|
///
|
||||||
|
/// assert_eq!("foo", s.as_str());
|
||||||
|
/// ```
|
||||||
#[inline]
|
#[inline]
|
||||||
#[stable(feature = "string_as_str", since = "1.7.0")]
|
#[stable(feature = "string_as_str", since = "1.7.0")]
|
||||||
pub fn as_str(&self) -> &str {
|
pub fn as_str(&self) -> &str {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue