Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

operator_element_at

crates.io ci codecov license

Emit the value at the given index then complete.

If the element at the specified index does not exist, because it had completed before reaching that index, the operator will either error with [ElementAtOperatorError::IndexOutOfRange] or emit a default value if one was provided.

See Also

Example

cargo run -p rx_core --example operator_element_at_example
let _subscription = vec!["a", "b", "c", "d", "e"]
    .into_observable()
    .element_at(2)
    .subscribe(PrintObserver::new("element_at_operator"));

Output:

element_at_operator - next: "c"
element_at_operator - completed
element_at_operator - unsubscribed