fn take
At most the first n elements; the element after them is never requested from s.
Example:
use std.stream { take }
fn nums() -> stream<i32> {
for i in 1..=100 { yield i }
}
fn main() io {
var out: List<i32> = []
for await x in nums() |> take(3) { out.push(x) }
print("{out}")
}Вывод
[1, 2, 3]
pub(api) fn take<T, E>(s: stream<T, E>, n: usize) -> stream<T, E>С версии. 1.0.0-beta
Параметры
| Имя | Тип |
|---|---|
s | stream<T, E> |
n | usize |
Возвращает
stream<T, E>
Эффекты
не объявлены (чистая, пока тело не говорит иное)
Определено в: std/stream/stream.oxl:106