Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

And if your callers are generic over the error type, and so they do have code for handling errors, the compiler won't emit this code for your result type because you've said its error type can't exist.


Does that mean you can assign the result of the function without explicitly unwrapping? Or that the compiler removes the call to unwrap? Or neither?


You need to unwrap but the compiler removes the call. If instead you know that the callee is infallible you can also do

    let Ok(x) = call_that_cant_fail();




Consider applying for YC's Winter 2027 batch! Applications are open till November 2.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: