operator_filter_map
Map values to an Option and keep only the Some values.
See Also
- FilterOperator - Keep values that satisfy a predicate.
- 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_map_example
let _subscription = (1..=5)
.into_observable()
.filter_map(|i| if i % 2 == 0 { Some(i) } else { None })
.subscribe(PrintObserver::new("filter_map_operator"));
Output:
filter_map_operator - next: 2
filter_map_operator - next: 4
filter_map_operator - completed
filter_map_operator - unsubscribed