2012-08-17 13:47:01 -05:00
|
|
|
// xfail-test - this isn't really a test.
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
// select!
|
2012-08-22 19:47:11 -05:00
|
|
|
macro_rules! select_if (
|
2012-08-17 13:47:01 -05:00
|
|
|
|
|
|
|
{
|
|
|
|
$index:expr,
|
|
|
|
$count:expr
|
|
|
|
} => {
|
|
|
|
fail
|
|
|
|
};
|
|
|
|
|
|
|
|
{
|
|
|
|
$index:expr,
|
|
|
|
$count:expr,
|
|
|
|
$port:path => [
|
|
|
|
$(type_this $message:path$(($(x $x: ident),+))dont_type_this*
|
2012-09-19 00:45:24 -05:00
|
|
|
-> $next:ident => { move $e:expr }),+
|
2012-08-17 13:47:01 -05:00
|
|
|
]
|
|
|
|
$(, $ports:path => [
|
|
|
|
$(type_this $messages:path$(($(x $xs: ident),+))dont_type_this*
|
2012-09-19 00:45:24 -05:00
|
|
|
-> $nexts:ident => { move $es:expr }),+
|
2012-08-17 13:47:01 -05:00
|
|
|
] )*
|
|
|
|
} => {
|
|
|
|
if $index == $count {
|
|
|
|
match move pipes::try_recv($port) {
|
2012-10-11 19:59:29 -05:00
|
|
|
$(Some($message($($(move $x,)+)* move next)) => {
|
2012-09-19 00:45:24 -05:00
|
|
|
let $next = move next;
|
|
|
|
move $e
|
2012-08-17 13:47:01 -05:00
|
|
|
})+
|
|
|
|
_ => fail
|
|
|
|
}
|
|
|
|
} else {
|
2012-08-22 19:24:52 -05:00
|
|
|
select_if!(
|
2012-08-17 13:47:01 -05:00
|
|
|
$index,
|
|
|
|
$count + 1
|
|
|
|
$(, $ports => [
|
|
|
|
$(type_this $messages$(($(x $xs),+))dont_type_this*
|
2012-09-19 00:45:24 -05:00
|
|
|
-> $nexts => { move $es }),+
|
2012-08-17 13:47:01 -05:00
|
|
|
])*
|
2012-08-22 19:24:52 -05:00
|
|
|
)
|
2012-08-17 13:47:01 -05:00
|
|
|
}
|
|
|
|
};
|
2012-08-22 19:47:11 -05:00
|
|
|
)
|
2012-08-17 13:47:01 -05:00
|
|
|
|
2012-08-22 19:47:11 -05:00
|
|
|
macro_rules! select (
|
2012-08-17 13:47:01 -05:00
|
|
|
{
|
|
|
|
$( $port:path => {
|
|
|
|
$($message:path$(($($x: ident),+))dont_type_this*
|
|
|
|
-> $next:ident $e:expr),+
|
|
|
|
} )+
|
|
|
|
} => {
|
|
|
|
let index = pipes::selecti([$(($port).header()),+]/_);
|
2012-08-22 19:24:52 -05:00
|
|
|
select_if!(index, 0 $(, $port => [
|
2012-09-19 00:45:24 -05:00
|
|
|
$(type_this $message$(($(x $x),+))dont_type_this* -> $next => { move $e }),+
|
2012-08-22 19:24:52 -05:00
|
|
|
])+)
|
2012-08-17 13:47:01 -05:00
|
|
|
}
|
2012-08-22 19:47:11 -05:00
|
|
|
)
|
2012-08-17 13:47:01 -05:00
|
|
|
|
|
|
|
}
|