fn first
The first element, or none for an empty stream. Cancels the producer; an error of the stream is returned.
Example:
use std.stream { first }
fn nums() -> stream<i32> {
for i in 5..8 { yield i }
}
fn main() io {
print("{nums() |> first()}")
}Output
5
pub(api) fn first<T, E>(s: stream<T, E>) -> T? | ESince. 1.0.0-beta
Parameters
| Name | Type |
|---|---|
s | stream<T, E> |
Returns
T?
Errors
E
Effects
none declared (pure unless the body says otherwise)
Defined in: std/stream/stream.oxl:221