Hacker News new | ask | show | jobs
by sezna 2227 days ago
it is intended to be read as “expect this to work”, or “expect this isn’t an error”
1 comments

But the argument is an error message, so it's not "expect this to work"...
That's technically the second argument. Just like in C++, when using a chained method, the first argument is implied to be the thing you're chaining on. So this is the same thing as calling Result::expect(File::open(&input_filename), "[ ERROR ] Failed to open file!"), but I've never actually seen someone ever use expect that way.

See also the definition of expect: https://doc.rust-lang.org/std/result/enum.Result.html#method...