fehler icon indicating copy to clipboard operation
fehler copied to clipboard

README: Remove explicit "return" from "Option" example

Open mgeier opened this issue 5 years ago • 2 comments

I might be missing something, but isn't that return unnecessary?

Since this is one of the differences between the Result and the Option example, it might imply to some readers that the Option case only works with explicit returns?

Or is there a reason to use return in one example but not in the other?

mgeier avatar Apr 11 '20 12:04 mgeier

The point was really to show that explicit return works. An ideal formulation would show both explicit and implicit return in both result and option examples.

withoutboats avatar Apr 11 '20 13:04 withoutboats

Yeah, I think it might be confusing if you throw in the explicit return just for the sake of it.

And Clippy doesn't seem to like it, either: https://rust-lang.github.io/rust-clippy/master/index.html#needless_return.

It seems like you are setting a bad example with this example.

I think you should make a separate example if you want to show that explicit returns also work.

mgeier avatar Apr 13 '20 16:04 mgeier