Rollup merge of #35062 - frewsxcv:chars-as-str, r=GuillaumeGomez

Add documentation example for `str::Chars::as_str`.

None
This commit is contained in:
Guillaume Gomez 2016-07-29 11:57:53 +02:00 committed by GitHub
commit 41c8d3f630

View File

@ -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 {