5 releases
Uses new Rust 2024
| new 0.2.1 | Feb 1, 2026 |
|---|---|
| 0.2.0 | Jan 24, 2026 |
| 0.1.2 | Jan 24, 2026 |
| 0.1.1 | Jan 23, 2026 |
| 0.1.0 | Jan 20, 2026 |
#2554 in Game dev
Used in 2 crates
(via rx_core)
170KB
4.5K
SLoC
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
Dependencies
~275–750KB
~18K SLoC