Skip to content

Commit 3e8fadc

Browse files
committed
Add doc example to String::as_str
Fixes #44428.
1 parent dee6d0f commit 3e8fadc

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)