Add documentation example for str::Chars::as_str
.
This commit is contained in:
parent
feeca94573
commit
f98c55d933
1 changed files with 13 additions and 0 deletions
|
@ -459,6 +459,19 @@ impl<'a> Chars<'a> {
|
||||||
///
|
///
|
||||||
/// This has the same lifetime as the original slice, and so the
|
/// This has the same lifetime as the original slice, and so the
|
||||||
/// iterator can continue to be used while this exists.
|
/// 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")]
|
#[stable(feature = "iter_to_slice", since = "1.4.0")]
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn as_str(&self) -> &'a str {
|
pub fn as_str(&self) -> &'a str {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue