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")
}
}Output
first 5
pub(api) move fn first() -> T | E | noneComplexity. O(1) plus the wait for the producer.
Since. 1.0.0-beta
Returns
T
Errors
Enone
Effects
none declared (pure unless the body says otherwise)
Defined in: std/core/stream.oxl:118