Skip to main content
Journey Uncommon Logo
JourneyUncommon
mediumRustFrom and Into conversionsSingle-choice MCQ

What does the `?` operator do with the error type when the function's error type differs from the one returned by a fallible call?

use std::num::ParseIntError; #[derive(Debug)] struct MyErr; impl From<ParseIntError> for MyErr { fn from(_: ParseIntError) -> MyErr { MyErr } } fn parse(s: &str) -> Result<i32, MyErr> { let n: i32 = s.parse()?; // s.parse() returns Result<i32, ParseIntError> Ok(n) }