Cannot use `?` operator for functions that return Result [duplicate]

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();

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)