operator_filter
Keep values that satisfy a predicate.
See Also
- FilterMapOperator -
Map values to an
Optionand keep only theSomevalues. - TakeOperator -
Emit only the first
nvalues, then complete. - SkipOperator -
Drop the first
nvalues. - LiftOptionOperator -
Filter out
Noneand forwardSomevalues.
Example
cargo run -p rx_core --example operator_filter_example
let _subscription = (1..=5)
.into_observable()
.map(|next: i32| next + 1)
.filter(|i, _| i > &2)
.subscribe(PrintObserver::new("filter_operator"));
Output:
filter_operator - next: 3
filter_operator - next: 4
filter_operator - next: 5
filter_operator - next: 6
filter_operator - completed
filter_operator - unsubscribed