about summary refs log tree commit diff
path: root/src/liballoc/string.rs
diff options
context:
space:
mode:
authorTommy Ip <hkmp7tommy@gmail.com>2017-09-09 09:05:54 +0100
committerTommy Ip <hkmp7tommy@gmail.com>2017-09-09 09:05:54 +0100
commit3e8fadc2ac5d5e25aaf0449d50988c54be92dbe4 (patch)
tree78ac32757e3b5f1c60891626b6abfe4526454710 /src/liballoc/string.rs
parentdee6d0f62e3b8bf8e58c4106f0f9bb54237c0807 (diff)
downloadrust-3e8fadc2ac5d5e25aaf0449d50988c54be92dbe4.tar.gz
rust-3e8fadc2ac5d5e25aaf0449d50988c54be92dbe4.zip
Add doc example to String::as_str
Fixes #44428.
Diffstat (limited to 'src/liballoc/string.rs')
-rw-r--r--src/liballoc/string.rs10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/liballoc/string.rs b/src/liballoc/string.rs
index ddb23b2ef37..1708f3e3987 100644
--- a/src/liballoc/string.rs
+++ b/src/liballoc/string.rs
@@ -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 {