OxL Reference

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:

oxl✓ checked in CI
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 | none

Complexity. O(1) plus the wait for the producer.

Since. 1.0.0-beta

Returns

T

Errors

  • E
  • none

Effects

none declared (pure unless the body says otherwise)

Defined in: std/core/stream.oxl:118

See also