-
Notifications
You must be signed in to change notification settings - Fork 339
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
expose try_recv and try_send on channels #585
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!!
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes please, I was recently searching for eactly this
4911264
to
9c3f28e
Compare
Signed-off-by: Yoshua Wuyts <[email protected]>
Signed-off-by: Yoshua Wuyts <[email protected]>
Signed-off-by: Yoshua Wuyts <[email protected]>
Signed-off-by: Yoshua Wuyts <[email protected]>
9c3f28e
to
b7c7efc
Compare
@dignifiedquire fixed the doctests, fingers crossed it passes now. |
Exposes
Receiver::try_recv
andSender::try_send
on 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