News for hackers. Stuff that matters.
Re:Getting started with Rust by building a tiny Markdown com... by sezna on Saturday May 16, 2020 @05:50PM (#23207511)
it is intended to be read as “expect this to work”, or “expect this isn’t an error”
Re:Getting started with Rust by building a tiny Markdown com... by einpoklum on Saturday May 16, 2020 @06:41PM (#23207803)
But the argument is an error message, so it's not "expect this to work"...
Re:Getting started with Rust by building a tiny Markdown com... by azdle on Saturday May 16, 2020 @06:54PM (#23207884)
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...