Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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...




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: