mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-22 18:15:07 +03:00
Clarify the documentation of take
This commit is contained in:
@@ -1180,6 +1180,17 @@ fn skip(self, n: usize) -> Skip<Self>
|
||||
/// assert_eq!(iter.next(), Some(2));
|
||||
/// assert_eq!(iter.next(), None);
|
||||
/// ```
|
||||
///
|
||||
/// If less than `n` elements are available,
|
||||
/// `take` will limit itself to the size of the underlying iterator:
|
||||
///
|
||||
/// ```
|
||||
/// let v = vec![1, 2];
|
||||
/// let mut iter = v.into_iter().take(5);
|
||||
/// assert_eq!(iter.next(), Some(1));
|
||||
/// assert_eq!(iter.next(), Some(2));
|
||||
/// assert_eq!(iter.next(), None);
|
||||
/// ```
|
||||
#[inline]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
fn take(self, n: usize) -> Take<Self>
|
||||
|
||||
Reference in New Issue
Block a user