method stream.first
The next element, the error that ended the stream, or none at its end (await sub.first() in [С V.5], D-6109).
Example:
fn numbers() -> stream<i64> {
yield 5
yield 6
}
fn main() io {
match numbers().first() {
i64 v => print("first {v}")
none => print("empty")
}
}Вывод
first 5
pub(api) move fn first() -> T | E | noneСложность. O(1) plus the wait for the producer.
С версии. 1.0.0-beta
Возвращает
T
Ошибки
Enone
Эффекты
не объявлены (чистая, пока тело не говорит иное)
Определено в: std/core/stream.oxl:118