You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I don't think it should, because it introduces a new class of potential bugs. The current design prevents the user from falling into the trap of thinking that tap returns the value that the closure returns.
Here's a contrived example where the user might believe that this would print "HELLO HELLO", but it would only print "HELLO".
use tap::prelude::*;fnechoed(s:&str) -> String{
s.to_string() + " " + s
}fnmain(){let echo = "hello".to_ascii_uppercase().tap(|s| echoed(s));println!("{echo}");}
I code this:
Getting error message:
It can be solved by adding brace and semicolon to the closure, but that doesn't seem ergonomic enough.
Do you think
tap
should allow the closure to return an ignorable value?The text was updated successfully, but these errors were encountered: