method iter.take
The first n elements; the element after them is never pulled.
Example:
fn main() io {
print("{[1, 2, 3, 4].iter().take(2).collect()}")
}Вывод
[1, 2]
pub(api) move fn take<I>(n: I) -> iter<T>Сложность. O(1) to build; pulls at most `n` elements of the source.
С версии. 1.0.0-beta
Параметры
| Имя | Тип |
|---|---|
n | I |
Возвращает
iter<T>
Эффекты
не объявлены (чистая, пока тело не говорит иное)
Определено в: std/core/iter.oxl:196