Como posso transformar idiomaticamente um Result
tipo em outro Result
tipo com base no Ok
valor?
fn get_res1() -> Result<bool, ()> {
Ok(true)
}
fn get_res2() -> Result<(), String> {
let res = get_res1().map_err(|err| String::from("Execution failed"))?;
// map Ok value to Result type(function return type) based on its value
// Is it possible to combine the below transformation with the above Result type method map_err?
if !res {
return Err(String::from("Operation failed"));
}
Ok(())
}