Hi everyone, thanks for the input. Let me restate the intent and address a few comments.
Intent #1: Ignoring the return value that occurred in a "Context"
The only two contexts (re: Monads) we care about in Rust are
Result. It is common to want to ignore the result of some operation that returned in a context, as shown above with
It has been shown above that there are currently two ways of doing this already:
.map(|_| ()) and
.map(drop). However, neither of these are the best approach in my mind, as the former is "code smelly" and the latter is "scary". Further, since neither is a method call, there is no documentation as to their intent.
void (or similarly named) would have docs and examples.
One might be inclined to say that
void is so trivial that it's a waste to implement it, but there are plenty of such one-liner methods in
std that this shouldn't be a reason not to add it.
re: not adding
Option::void. My gut still says it would be useful, likely in the case of the "switcheroo"
FromIterator instance for
Intent #2: Improve ergonomics when
void is called on the last line
The auto-lifting of the Error type could be optional here. I added it here to reduce overall boilerplate that is otherwise incurred by (arguably underpowered)
Talking to some peers, we speculated that in an ideal world,
; would respect context, and not just evaluate to
() regardless. If anyone else likes that idea, we could open a new thread to discuss it and let
void just be concerned with "dropping to
Otherwise, I'm not a fan of
try blocks, as the goal was to reduce code length, and I'm generally allergic to the addition of syntax to accomplish what is already possible with functions (I'm looking at you, Golang). Further,
try blocks were added to nightly five years ago. They may never be merged, and I'm looking for a sustainable solution for Stable Rust.