Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

operator_lift_result

crates.io ci codecov license

Split Result values into next and error signals.

See Also

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