expose try_recv and try_send on channels#585
Conversation
|
How do you feel about this mild inconsistency where we sometimes use fn try_recv(&self) -> Result<T, TryRecvError>;
fn recv(&self) -> Option<T>;
fn next(&self) -> Option<T>;Or, to put it differently, should |
|
@stjepang Interesting! On the other hand This is interesting; hadn't thought of this. I was going to say that the current state is good, but now looking at what |
|
Yeah... in that case, are you okay with fn recv(&self) -> Result<T, RecvError>;
fn next(&self) -> Option<T>; |
|
@stjepang yeah, that sounds good. Seems to be the same in |
|
Note from triage: we should remove the |
|
Is this a good alternative? use futures::prelude::FutureExt;
fn try_send<T>(chan: Sender<T>, x: T) -> bool {
chan.send(x).now_or_never().is_some()
} |
|
@stjepang actually I'm unsure how to remove that case. Maybe let's leave it in for now and consider changing it as part of stabilization? edit: defined a new type |
|
ping @stjepang |
dignifiedquire
left a comment
There was a problem hiding this comment.
yes please, I was recently searching for eactly this
4911264 to
9c3f28e
Compare
Signed-off-by: Yoshua Wuyts <yoshuawuyts@gmail.com>
Signed-off-by: Yoshua Wuyts <yoshuawuyts@gmail.com>
Signed-off-by: Yoshua Wuyts <yoshuawuyts@gmail.com>
9c3f28e to
b7c7efc
Compare
|
@dignifiedquire fixed the doctests, fingers crossed it passes now. |
Exposes
Receiver::try_recvandSender::try_sendon channels. Closes #579. I'm proposing we put the types in the crate's top-level because we're still undecided. I'd like to move to unblock people first, and then consider how we might want to move types around. Thanks!Screenshot