From: Tommy Ip Date: Sat, 9 Sep 2017 08:05:54 +0000 (+0100) Subject: Add doc example to String::as_str X-Git-Url: https://git.lizzy.rs/?a=commitdiff_plain;h=3e8fadc2ac5d5e25aaf0449d50988c54be92dbe4;p=rust.git Add doc example to String::as_str Fixes #44428. --- 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 @@ pub fn into_bytes(self) -> Vec { } /// 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 {