operator_lift_result
Split Result values into next and error signals.
See Also
- CatchOperator - On error, switch to a recovery observable.
- RetryOperator - Resubscribe on error up to the configured retry count.
- IntoResultOperator -
Capture next/error signals as
Resultvalues. - ErrorBoundaryOperator -
Enforce
Neveras the error type to guard pipelines at compile time.
Example
cargo run -p rx_core --example operator_lift_result_example
use rx_core::prelude::*;
fn main() {
let _s = (1..=5)
.into_observable()
.map(|i| {
if i <= 3 {
Result::<i32, String>::Ok(i)
} else {
Result::<i32, String>::Err("Larger than 3!".to_string())
}
})
// We're lifting the result error from the "next" channel, but we still have to deal with
// upstream errors if they exist, this `unreachable!` is just here to ignore them.
.lift_result()
.subscribe(PrintObserver::new("lift_result_operator"));
}
lift_result_operator - next: 1
lift_result_operator - next: 2
lift_result_operator - next: 3
lift_result_operator - error: "Larger than 3!"
lift_result_operator - unsubscribed