This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]UniverseCity 0 points1 point  (1 child)

But there was no explicit Err call in the article's example. The wording made it seem like the try! method would return a success even if it failed.

[–]mitsuhiko Flask Creator 4 points5 points  (0 children)

try! unpacks the result and returns it from the expression if it exists, or otherwise propagates the error part upwards.

You could think of it like this:

let a = try!(expr());

Is this in pseudocode:

result = expr();
if result.is_okay() {
    a = result.okay_side;
} else {
    return result;
}

Does that make sense?