Is there an ergonomic ? that works with Result, E2>
⚓ Rust 📅 2025-06-26 👤 surdeus 👁️ 18If I have type T1: Into<E1>, and type T2: Into<E2>, I can't seem get something like this to compile:
fn func() -> Result<Result<T, E1>, E2> {
function1()?;
function2()?;
Ok((T::new()))
}
where fn function1() -> Result<(), T1>, and fn function2() -> Result<(), T2>.
Maybe I am asking too much from the ? operator.
Is the only way to make this work to match on all calls that could return an error, and return the properly formed Ok(Err(E1)) or Err(E2)?
4 posts - 3 participants
🏷️ rust_feed