Skip to content
Better HN
Top
New
Best
Ask
Show
Jobs
Search
⌘K
undefined | Better HN
0 points
steveklabnik
5y ago
0 comments
Share
This code is identical to
let file = file.expect("file was null");
That is, the "expect" method does exactly this.
0 comments
default
newest
oldest
jeswin
5y ago
I like Rust from what I've tried. But I'd have preferred something like this:
let file = file.unwrapOrPanicWith("file was null");
option.expect(message) doesn't semantically make sense.
steveklabnik
OP
5y ago
There was some discussion about this when the method was named; you're not alone. In the end, it is what it is. You could define your own method like that if you really wanted to.
jack1243star
5y ago
I read it as expect (prepare) for the worst!
j
/
k
navigate · click thread line to collapse