.expect() (or .unwrap()) are not error handling mechanisms, and certainly not equivalent to if err != nil in Go. The usual error handling mechanism in Rust is the ? operators, that has the same meaning as if err == nil { return; }.
.expect()
.unwrap()
if err != nil
?
if err == nil { return; }
Would that be done like this?:
if let Err(Reason) = somefunc() { // handle error? }
Or match.
match
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
.expect()
(or.unwrap()
) are not error handling mechanisms, and certainly not equivalent toif err != nil
in Go. The usual error handling mechanism in Rust is the?
operators, that has the same meaning asif err == nil { return; }
.Would that be done like this?:
Or
match
.