Open
Description
It would be nice if it was possible to guard some arms with #[cfg]
in the select macro.
For example: (based on the example of https://docs.rs/crossbeam/latest/crossbeam/macro.select.html#examples , but adding a channel2 feature )
use crossbeam_channel::{select, unbounded};
let (s1, r1) = unbounded();
#[cfg(feature = "channel2")]
let (s2, r2) = unbounded();
s1.send(10).unwrap();
// Since both operations are initially ready, a random one will be executed.
select! {
recv(r1) -> msg => assert_eq!(msg, Ok(10)),
#[cfg(feature = "channel2")]
send(s2, 20) -> res => {
assert_eq!(res, Ok(()));
assert_eq!(r2.recv(), Ok(20));
}
}
I know that the workaround is to use Select
directly, but I'd thought this would be convenient and natural.