Skip to content

Commit

Permalink
Add doc example to String::as_str
Browse files Browse the repository at this point in the history
Fixes #44428.
  • Loading branch information
tommyip committed Sep 9, 2017
1 parent dee6d0f commit 3e8fadc
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 3e8fadc

Please sign in to comment.