method iter.takeWhile
The elements up to (not including) the first one for which p is false.
Example:
fn main() io {
print("{[1, 2, 5, 1].iter().takeWhile(x => x < 3).collect()}")
}Вывод
[1, 2]
pub(api) move fn takeWhile<effect F>(p: fn(T) -> bool F escaping) -> iter<T> FСложность. O(1) to build; stops pulling at the first failing element.
С версии. 1.0.0-beta
Параметры
| Имя | Тип |
|---|---|
p | fn(T) -> bool F escaping |
Возвращает
iter<T> F
Эффекты
не объявлены (чистая, пока тело не говорит иное)
Определено в: std/core/iter.oxl:244