Skip to content

Commit 8a6c9b5

Browse files
authored
Rollup merge of #44449 - tommyip:doc_string_as_str, r=frewsxcv
Add doc example to String::as_str Fixes #44428.
2 parents 6482acd + 3e8fadc commit 8a6c9b5

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/liballoc/string.rs

+10
Original file line numberDiff line numberDiff line change
@@ -743,6 +743,16 @@ impl String {
743743
}
744744

745745
/// Extracts a string slice containing the entire string.
746+
///
747+
/// # Examples
748+
///
749+
/// Basic usage:
750+
///
751+
/// ```
752+
/// let s = String::from("foo");
753+
///
754+
/// assert_eq!("foo", s.as_str());
755+
/// ```
746756
#[inline]
747757
#[stable(feature = "string_as_str", since = "1.7.0")]
748758
pub fn as_str(&self) -> &str {

0 commit comments

Comments
 (0)