Closed spearman closed 7 years ago
This is very cool, @spearman, thanks for contributing!
Before we merge this, do you think it would be possible to write a couple of simple tests, perhaps like the one in test/send_recv.rs?
Added a test for try_recv, there is also an example program in the first commit using try_offer! macro
Thanks!
New methods for
try_recv
andtry_offer
rely on new internal methodtry_read_chan
that callsmpsc::try_recv
and returns an option containing the value if one was pending, and panicking if the channel was closed prematurely.The
offer!
macro is adapted to thetry_offer!
macro which returns the unmodified channel wrapped inErr
if no messages were pending. This means the user-defined branches need to return a result, namely the new channel in the chosen branch wrapped inOk
.