Closed
Description
Consider these two functions:
pub fn bar(x: Result<String, String>) -> Result<String, String> {
Ok(x?)
}
pub fn baz(x: Result<String, String>) -> Result<String, String> {
x
}
Ideally the compiler should generate identical machine code. But it does not.
Because of this issue, ?
operator is not as convenient to use in high performance parts of code. E. g.
fn f() -> Result<(), MyError> {
f1()?;
f2()?;
Ok(())
}
has to be written for performance as
fn f() -> Result<(), MyError> {
f1()?;
f2()
}