about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume1.gomez@gmail.com>2016-07-29 11:57:53 +0200
committerGitHub <noreply@github.com>2016-07-29 11:57:53 +0200
commit41c8d3f63017151b08577ecbefbc60c154e8324f (patch)
treea085b4fa601fed1f741eabb92ef6fac197d4fb0f /src
parent72d1d066921ead93d64b4b01252caba347efa3f6 (diff)
parentf98c55d933d24a806cee85bb0239682b39a23e32 (diff)
downloadrust-41c8d3f63017151b08577ecbefbc60c154e8324f.tar.gz
rust-41c8d3f63017151b08577ecbefbc60c154e8324f.zip
Rollup merge of #35062 - frewsxcv:chars-as-str, r=GuillaumeGomez
Add documentation example for `str::Chars::as_str`.

None
Diffstat (limited to 'src')
-rw-r--r--src/libcore/str/mod.rs13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/libcore/str/mod.rs b/src/libcore/str/mod.rs
index a32c9da9815..fdcadd43a0f 100644
--- a/src/libcore/str/mod.rs
+++ b/src/libcore/str/mod.rs
@@ -459,6 +459,19 @@ impl<'a> Chars<'a> {
     ///
     /// This has the same lifetime as the original slice, and so the
     /// iterator can continue to be used while this exists.
+    ///
+    /// # Examples
+    ///
+    /// ```
+    /// let mut chars = "abc".chars();
+    ///
+    /// assert_eq!(chars.as_str(), "abc");
+    /// chars.next();
+    /// assert_eq!(chars.as_str(), "bc");
+    /// chars.next();
+    /// chars.next();
+    /// assert_eq!(chars.as_str(), "");
+    /// ```
     #[stable(feature = "iter_to_slice", since = "1.4.0")]
     #[inline]
     pub fn as_str(&self) -> &'a str {