Thoughts on this idea for a new `select!` syntax in crossbeam-channel? select! { recv(r, msg) => {} // `msg` is of type `Result<T, RecvError>` send(s, msg) => {} default(Duration::from_secs(1)) => {} } The Go equivalent is in the next tweet.
-
Show this thread
-
select { case msg, ok := <-r: case s <- msg: case <-time.After(1 * time.Second): } Also, do you think this code in Rust should panic if `s` is closed? I'm asking because that's what would happen in Go.
@burntsushi5 - do you perhaps have an opinion?2 replies 0 retweets 0 likesShow this thread -
Replying to @stjepang
I don't think I have a strong opinion. One idea I have in my head is that it should be possible for people to use channels without writing `unwrap` everywhere. :-)
1 reply 0 retweets 1 like -
Replying to @burntsushi5
In that case, what should sending a message into a closed channel do? Channels in Go panic, while the chan crate simply leaks the message. The latter is worse, IMO, since that just silently ignores the error.
1 reply 0 retweets 0 likes
I like the idea of a panic. (An additional API that returns an error might be a good idea too.)
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.