File tree 1 file changed +13
-2
lines changed
library/core/src/iter/traits
1 file changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -1228,7 +1228,11 @@ pub trait Iterator {
1228
1228
1229
1229
/// Creates an iterator that skips the first `n` elements.
1230
1230
///
1231
- /// After they have been consumed, the rest of the elements are yielded.
1231
+ /// `skip(n)` skips elements until `n` elements are skipped or the end of the
1232
+ /// iterator is reached (whichever happens first). After that, all the remaining
1233
+ /// elements are yielded. In particular, if the original iterator is too short,
1234
+ /// then the returned iterator is empty.
1235
+ ///
1232
1236
/// Rather than overriding this method directly, instead override the `nth` method.
1233
1237
///
1234
1238
/// # Examples
@@ -1252,7 +1256,14 @@ pub trait Iterator {
1252
1256
Skip :: new ( self , n)
1253
1257
}
1254
1258
1255
- /// Creates an iterator that yields its first `n` elements.
1259
+ /// Creates an iterator that yields the first `n` elements, or fewer
1260
+ /// if the underlying iterator ends sooner.
1261
+ ///
1262
+ /// `take(n)` yields elements until `n` elements are yielded or the end of
1263
+ /// the iterator is reached (whichever happens first).
1264
+ /// The returned iterator is a prefix of length `n` if the original iterator
1265
+ /// contains at least `n` elements, otherwise it contains all of the
1266
+ /// (fewer than `n`) elements of the original iterator.
1256
1267
///
1257
1268
/// # Examples
1258
1269
///
You can’t perform that action at this time.
0 commit comments