What do you want to happen if function()
returns an Err
result? You can’t use try!
/?
because it causes the containing function to return the same Err
, but main()
can’t return an Err
(it returns ()
, not Result<…>
). If you want to panic, you can use unwrap:
function().unwrap();
If you want to ignore errors, discard the result:
let _ = function();