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()}")
}Output
[1, 2]
pub(api) move fn takeWhile<effect F>(p: fn(T) -> bool F escaping) -> iter<T> FComplexity. O(1) to build; stops pulling at the first failing element.
Since. 1.0.0-beta
Parameters
| Name | Type |
|---|---|
p | fn(T) -> bool F escaping |
Returns
iter<T> F
Effects
none declared (pure unless the body says otherwise)
Defined in: std/core/iter.oxl:244