operator_element_at
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
- FindOperator - Emit the first value that matches a predicate.
- FilterOperator - Keep values that satisfy a predicate.
- FirstOperator - Emit only the first value, then complete.
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