• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /// Waits on multiple concurrent branches, returning when the **first** branch
2 /// completes, cancelling the remaining branches.
3 ///
4 /// The `select!` macro must be used inside of async functions, closures, and
5 /// blocks.
6 ///
7 /// The `select!` macro accepts one or more branches with the following pattern:
8 ///
9 /// ```text
10 /// <pattern> = <async expression> (, if <precondition>)? => <handler>,
11 /// ```
12 ///
13 /// Additionally, the `select!` macro may include a single, optional `else`
14 /// branch, which evaluates if none of the other branches match their patterns:
15 ///
16 /// ```text
17 /// else => <expression>
18 /// ```
19 ///
20 /// The macro aggregates all `<async expression>` expressions and runs them
21 /// concurrently on the **current** task. Once the **first** expression
22 /// completes with a value that matches its `<pattern>`, the `select!` macro
23 /// returns the result of evaluating the completed branch's `<handler>`
24 /// expression.
25 ///
26 /// Additionally, each branch may include an optional `if` precondition. If the
27 /// precondition returns `false`, then the branch is disabled. The provided
28 /// `<async expression>` is still evaluated but the resulting future is never
29 /// polled. This capability is useful when using `select!` within a loop.
30 ///
31 /// The complete lifecycle of a `select!` expression is as follows:
32 ///
33 /// 1. Evaluate all provided `<precondition>` expressions. If the precondition
34 ///    returns `false`, disable the branch for the remainder of the current call
35 ///    to `select!`. Re-entering `select!` due to a loop clears the "disabled"
36 ///    state.
37 /// 2. Aggregate the `<async expression>`s from each branch, including the
38 ///    disabled ones. If the branch is disabled, `<async expression>` is still
39 ///    evaluated, but the resulting future is not polled.
40 /// 3. Concurrently await on the results for all remaining `<async expression>`s.
41 /// 4. Once an `<async expression>` returns a value, attempt to apply the value
42 ///    to the provided `<pattern>`, if the pattern matches, evaluate `<handler>`
43 ///    and return. If the pattern **does not** match, disable the current branch
44 ///    and for the remainder of the current call to `select!`. Continue from step 3.
45 /// 5. If **all** branches are disabled, evaluate the `else` expression. If no
46 ///    else branch is provided, panic.
47 ///
48 /// # Runtime characteristics
49 ///
50 /// By running all async expressions on the current task, the expressions are
51 /// able to run **concurrently** but not in **parallel**. This means all
52 /// expressions are run on the same thread and if one branch blocks the thread,
53 /// all other expressions will be unable to continue. If parallelism is
54 /// required, spawn each async expression using [`tokio::spawn`] and pass the
55 /// join handle to `select!`.
56 ///
57 /// [`tokio::spawn`]: crate::spawn
58 ///
59 /// # Fairness
60 ///
61 /// By default, `select!` randomly picks a branch to check first. This provides
62 /// some level of fairness when calling `select!` in a loop with branches that
63 /// are always ready.
64 ///
65 /// This behavior can be overridden by adding `biased;` to the beginning of the
66 /// macro usage. See the examples for details. This will cause `select` to poll
67 /// the futures in the order they appear from top to bottom. There are a few
68 /// reasons you may want this:
69 ///
70 /// - The random number generation of `tokio::select!` has a non-zero CPU cost
71 /// - Your futures may interact in a way where known polling order is significant
72 ///
73 /// But there is an important caveat to this mode. It becomes your responsibility
74 /// to ensure that the polling order of your futures is fair. If for example you
75 /// are selecting between a stream and a shutdown future, and the stream has a
76 /// huge volume of messages and zero or nearly zero time between them, you should
77 /// place the shutdown future earlier in the `select!` list to ensure that it is
78 /// always polled, and will not be ignored due to the stream being constantly
79 /// ready.
80 ///
81 /// # Panics
82 ///
83 /// The `select!` macro panics if all branches are disabled **and** there is no
84 /// provided `else` branch. A branch is disabled when the provided `if`
85 /// precondition returns `false` **or** when the pattern does not match the
86 /// result of `<async expression>`.
87 ///
88 /// # Cancellation safety
89 ///
90 /// When using `select!` in a loop to receive messages from multiple sources,
91 /// you should make sure that the receive call is cancellation safe to avoid
92 /// losing messages. This section goes through various common methods and
93 /// describes whether they are cancel safe.  The lists in this section are not
94 /// exhaustive.
95 ///
96 /// The following methods are cancellation safe:
97 ///
98 ///  * [`tokio::sync::mpsc::Receiver::recv`](crate::sync::mpsc::Receiver::recv)
99 ///  * [`tokio::sync::mpsc::UnboundedReceiver::recv`](crate::sync::mpsc::UnboundedReceiver::recv)
100 ///  * [`tokio::sync::broadcast::Receiver::recv`](crate::sync::broadcast::Receiver::recv)
101 ///  * [`tokio::sync::watch::Receiver::changed`](crate::sync::watch::Receiver::changed)
102 ///  * [`tokio::net::TcpListener::accept`](crate::net::TcpListener::accept)
103 ///  * [`tokio::net::UnixListener::accept`](crate::net::UnixListener::accept)
104 ///  * [`tokio::signal::unix::Signal::recv`](crate::signal::unix::Signal::recv)
105 ///  * [`tokio::io::AsyncReadExt::read`](crate::io::AsyncReadExt::read) on any `AsyncRead`
106 ///  * [`tokio::io::AsyncReadExt::read_buf`](crate::io::AsyncReadExt::read_buf) on any `AsyncRead`
107 ///  * [`tokio::io::AsyncWriteExt::write`](crate::io::AsyncWriteExt::write) on any `AsyncWrite`
108 ///  * [`tokio::io::AsyncWriteExt::write_buf`](crate::io::AsyncWriteExt::write_buf) on any `AsyncWrite`
109 ///  * [`tokio_stream::StreamExt::next`](https://docs.rs/tokio-stream/0.1/tokio_stream/trait.StreamExt.html#method.next) on any `Stream`
110 ///  * [`futures::stream::StreamExt::next`](https://docs.rs/futures/0.3/futures/stream/trait.StreamExt.html#method.next) on any `Stream`
111 ///
112 /// The following methods are not cancellation safe and can lead to loss of data:
113 ///
114 ///  * [`tokio::io::AsyncReadExt::read_exact`](crate::io::AsyncReadExt::read_exact)
115 ///  * [`tokio::io::AsyncReadExt::read_to_end`](crate::io::AsyncReadExt::read_to_end)
116 ///  * [`tokio::io::AsyncReadExt::read_to_string`](crate::io::AsyncReadExt::read_to_string)
117 ///  * [`tokio::io::AsyncWriteExt::write_all`](crate::io::AsyncWriteExt::write_all)
118 ///
119 /// The following methods are not cancellation safe because they use a queue for
120 /// fairness and cancellation makes you lose your place in the queue:
121 ///
122 ///  * [`tokio::sync::Mutex::lock`](crate::sync::Mutex::lock)
123 ///  * [`tokio::sync::RwLock::read`](crate::sync::RwLock::read)
124 ///  * [`tokio::sync::RwLock::write`](crate::sync::RwLock::write)
125 ///  * [`tokio::sync::Semaphore::acquire`](crate::sync::Semaphore::acquire)
126 ///  * [`tokio::sync::Notify::notified`](crate::sync::Notify::notified)
127 ///
128 /// To determine whether your own methods are cancellation safe, look for the
129 /// location of uses of `.await`. This is because when an asynchronous method is
130 /// cancelled, that always happens at an `.await`. If your function behaves
131 /// correctly even if it is restarted while waiting at an `.await`, then it is
132 /// cancellation safe.
133 ///
134 /// Cancellation safety can be defined in the following way: If you have a
135 /// future that has not yet completed, then it must be a no-op to drop that
136 /// future and recreate it. This definition is motivated by the situation where
137 /// a `select!` is used in a loop. Without this guarantee, you would lose your
138 /// progress when another branch completes and you restart the `select!` by
139 /// going around the loop.
140 ///
141 /// Be aware that cancelling something that is not cancellation safe is not
142 /// necessarily wrong. For example, if you are cancelling a task because the
143 /// application is shutting down, then you probably don't care that partially
144 /// read data is lost.
145 ///
146 /// # Examples
147 ///
148 /// Basic select with two branches.
149 ///
150 /// ```
151 /// async fn do_stuff_async() {
152 ///     // async work
153 /// }
154 ///
155 /// async fn more_async_work() {
156 ///     // more here
157 /// }
158 ///
159 /// #[tokio::main]
160 /// async fn main() {
161 ///     tokio::select! {
162 ///         _ = do_stuff_async() => {
163 ///             println!("do_stuff_async() completed first")
164 ///         }
165 ///         _ = more_async_work() => {
166 ///             println!("more_async_work() completed first")
167 ///         }
168 ///     };
169 /// }
170 /// ```
171 ///
172 /// Basic stream selecting.
173 ///
174 /// ```
175 /// use tokio_stream::{self as stream, StreamExt};
176 ///
177 /// #[tokio::main]
178 /// async fn main() {
179 ///     let mut stream1 = stream::iter(vec![1, 2, 3]);
180 ///     let mut stream2 = stream::iter(vec![4, 5, 6]);
181 ///
182 ///     let next = tokio::select! {
183 ///         v = stream1.next() => v.unwrap(),
184 ///         v = stream2.next() => v.unwrap(),
185 ///     };
186 ///
187 ///     assert!(next == 1 || next == 4);
188 /// }
189 /// ```
190 ///
191 /// Collect the contents of two streams. In this example, we rely on pattern
192 /// matching and the fact that `stream::iter` is "fused", i.e. once the stream
193 /// is complete, all calls to `next()` return `None`.
194 ///
195 /// ```
196 /// use tokio_stream::{self as stream, StreamExt};
197 ///
198 /// #[tokio::main]
199 /// async fn main() {
200 ///     let mut stream1 = stream::iter(vec![1, 2, 3]);
201 ///     let mut stream2 = stream::iter(vec![4, 5, 6]);
202 ///
203 ///     let mut values = vec![];
204 ///
205 ///     loop {
206 ///         tokio::select! {
207 ///             Some(v) = stream1.next() => values.push(v),
208 ///             Some(v) = stream2.next() => values.push(v),
209 ///             else => break,
210 ///         }
211 ///     }
212 ///
213 ///     values.sort();
214 ///     assert_eq!(&[1, 2, 3, 4, 5, 6], &values[..]);
215 /// }
216 /// ```
217 ///
218 /// Using the same future in multiple `select!` expressions can be done by passing
219 /// a reference to the future. Doing so requires the future to be [`Unpin`]. A
220 /// future can be made [`Unpin`] by either using [`Box::pin`] or stack pinning.
221 ///
222 /// [`Unpin`]: std::marker::Unpin
223 /// [`Box::pin`]: std::boxed::Box::pin
224 ///
225 /// Here, a stream is consumed for at most 1 second.
226 ///
227 /// ```
228 /// use tokio_stream::{self as stream, StreamExt};
229 /// use tokio::time::{self, Duration};
230 ///
231 /// #[tokio::main]
232 /// async fn main() {
233 ///     let mut stream = stream::iter(vec![1, 2, 3]);
234 ///     let sleep = time::sleep(Duration::from_secs(1));
235 ///     tokio::pin!(sleep);
236 ///
237 ///     loop {
238 ///         tokio::select! {
239 ///             maybe_v = stream.next() => {
240 ///                 if let Some(v) = maybe_v {
241 ///                     println!("got = {}", v);
242 ///                 } else {
243 ///                     break;
244 ///                 }
245 ///             }
246 ///             _ = &mut sleep => {
247 ///                 println!("timeout");
248 ///                 break;
249 ///             }
250 ///         }
251 ///     }
252 /// }
253 /// ```
254 ///
255 /// Joining two values using `select!`.
256 ///
257 /// ```
258 /// use tokio::sync::oneshot;
259 ///
260 /// #[tokio::main]
261 /// async fn main() {
262 ///     let (tx1, mut rx1) = oneshot::channel();
263 ///     let (tx2, mut rx2) = oneshot::channel();
264 ///
265 ///     tokio::spawn(async move {
266 ///         tx1.send("first").unwrap();
267 ///     });
268 ///
269 ///     tokio::spawn(async move {
270 ///         tx2.send("second").unwrap();
271 ///     });
272 ///
273 ///     let mut a = None;
274 ///     let mut b = None;
275 ///
276 ///     while a.is_none() || b.is_none() {
277 ///         tokio::select! {
278 ///             v1 = (&mut rx1), if a.is_none() => a = Some(v1.unwrap()),
279 ///             v2 = (&mut rx2), if b.is_none() => b = Some(v2.unwrap()),
280 ///         }
281 ///     }
282 ///
283 ///     let res = (a.unwrap(), b.unwrap());
284 ///
285 ///     assert_eq!(res.0, "first");
286 ///     assert_eq!(res.1, "second");
287 /// }
288 /// ```
289 ///
290 /// Using the `biased;` mode to control polling order.
291 ///
292 /// ```
293 /// #[tokio::main]
294 /// async fn main() {
295 ///     let mut count = 0u8;
296 ///
297 ///     loop {
298 ///         tokio::select! {
299 ///             // If you run this example without `biased;`, the polling order is
300 ///             // pseudo-random, and the assertions on the value of count will
301 ///             // (probably) fail.
302 ///             biased;
303 ///
304 ///             _ = async {}, if count < 1 => {
305 ///                 count += 1;
306 ///                 assert_eq!(count, 1);
307 ///             }
308 ///             _ = async {}, if count < 2 => {
309 ///                 count += 1;
310 ///                 assert_eq!(count, 2);
311 ///             }
312 ///             _ = async {}, if count < 3 => {
313 ///                 count += 1;
314 ///                 assert_eq!(count, 3);
315 ///             }
316 ///             _ = async {}, if count < 4 => {
317 ///                 count += 1;
318 ///                 assert_eq!(count, 4);
319 ///             }
320 ///
321 ///             else => {
322 ///                 break;
323 ///             }
324 ///         };
325 ///     }
326 /// }
327 /// ```
328 ///
329 /// ## Avoid racy `if` preconditions
330 ///
331 /// Given that `if` preconditions are used to disable `select!` branches, some
332 /// caution must be used to avoid missing values.
333 ///
334 /// For example, here is **incorrect** usage of `sleep` with `if`. The objective
335 /// is to repeatedly run an asynchronous task for up to 50 milliseconds.
336 /// However, there is a potential for the `sleep` completion to be missed.
337 ///
338 /// ```no_run,should_panic
339 /// use tokio::time::{self, Duration};
340 ///
341 /// async fn some_async_work() {
342 ///     // do work
343 /// }
344 ///
345 /// #[tokio::main]
346 /// async fn main() {
347 ///     let sleep = time::sleep(Duration::from_millis(50));
348 ///     tokio::pin!(sleep);
349 ///
350 ///     while !sleep.is_elapsed() {
351 ///         tokio::select! {
352 ///             _ = &mut sleep, if !sleep.is_elapsed() => {
353 ///                 println!("operation timed out");
354 ///             }
355 ///             _ = some_async_work() => {
356 ///                 println!("operation completed");
357 ///             }
358 ///         }
359 ///     }
360 ///
361 ///     panic!("This example shows how not to do it!");
362 /// }
363 /// ```
364 ///
365 /// In the above example, `sleep.is_elapsed()` may return `true` even if
366 /// `sleep.poll()` never returned `Ready`. This opens up a potential race
367 /// condition where `sleep` expires between the `while !sleep.is_elapsed()`
368 /// check and the call to `select!` resulting in the `some_async_work()` call to
369 /// run uninterrupted despite the sleep having elapsed.
370 ///
371 /// One way to write the above example without the race would be:
372 ///
373 /// ```
374 /// use tokio::time::{self, Duration};
375 ///
376 /// async fn some_async_work() {
377 /// # time::sleep(Duration::from_millis(10)).await;
378 ///     // do work
379 /// }
380 ///
381 /// #[tokio::main]
382 /// async fn main() {
383 ///     let sleep = time::sleep(Duration::from_millis(50));
384 ///     tokio::pin!(sleep);
385 ///
386 ///     loop {
387 ///         tokio::select! {
388 ///             _ = &mut sleep => {
389 ///                 println!("operation timed out");
390 ///                 break;
391 ///             }
392 ///             _ = some_async_work() => {
393 ///                 println!("operation completed");
394 ///             }
395 ///         }
396 ///     }
397 /// }
398 /// ```
399 #[macro_export]
400 #[cfg_attr(docsrs, doc(cfg(feature = "macros")))]
401 macro_rules! select {
402     // Uses a declarative macro to do **most** of the work. While it is possible
403     // to implement fully with a declarative macro, a procedural macro is used
404     // to enable improved error messages.
405     //
406     // The macro is structured as a tt-muncher. All branches are processed and
407     // normalized. Once the input is normalized, it is passed to the top-most
408     // rule. When entering the macro, `@{ }` is inserted at the front. This is
409     // used to collect the normalized input.
410     //
411     // The macro only recurses once per branch. This allows using `select!`
412     // without requiring the user to increase the recursion limit.
413 
414     // All input is normalized, now transform.
415     (@ {
416         // The index of the future to poll first (in bias mode), or the RNG
417         // expression to use to pick a future to poll first.
418         start=$start:expr;
419 
420         // One `_` for each branch in the `select!` macro. Passing this to
421         // `count!` converts $skip to an integer.
422         ( $($count:tt)* )
423 
424         // Normalized select branches. `( $skip )` is a set of `_` characters.
425         // There is one `_` for each select branch **before** this one. Given
426         // that all input futures are stored in a tuple, $skip is useful for
427         // generating a pattern to reference the future for the current branch.
428         // $skip is also used as an argument to `count!`, returning the index of
429         // the current select branch.
430         $( ( $($skip:tt)* ) $bind:pat = $fut:expr, if $c:expr => $handle:expr, )+
431 
432         // Fallback expression used when all select branches have been disabled.
433         ; $else:expr
434 
435     }) => {{
436         // Enter a context where stable "function-like" proc macros can be used.
437         //
438         // This module is defined within a scope and should not leak out of this
439         // macro.
440         #[doc(hidden)]
441         mod __tokio_select_util {
442             // Generate an enum with one variant per select branch
443             $crate::select_priv_declare_output_enum!( ( $($count)* ) );
444         }
445 
446         // `tokio::macros::support` is a public, but doc(hidden) module
447         // including a re-export of all types needed by this macro.
448         use $crate::macros::support::Future;
449         use $crate::macros::support::Pin;
450         use $crate::macros::support::Poll::{Ready, Pending};
451 
452         const BRANCHES: u32 = $crate::count!( $($count)* );
453 
454         let mut disabled: __tokio_select_util::Mask = Default::default();
455 
456         // First, invoke all the pre-conditions. For any that return true,
457         // set the appropriate bit in `disabled`.
458         $(
459             if !$c {
460                 let mask: __tokio_select_util::Mask = 1 << $crate::count!( $($skip)* );
461                 disabled |= mask;
462             }
463         )*
464 
465         // Create a scope to separate polling from handling the output. This
466         // adds borrow checker flexibility when using the macro.
467         let mut output = {
468             // Safety: Nothing must be moved out of `futures`. This is to
469             // satisfy the requirement of `Pin::new_unchecked` called below.
470             //
471             // We can't use the `pin!` macro for this because `futures` is a
472             // tuple and the standard library provides no way to pin-project to
473             // the fields of a tuple.
474             let mut futures = ( $( $fut , )+ );
475 
476             // This assignment makes sure that the `poll_fn` closure only has a
477             // reference to the futures, instead of taking ownership of them.
478             // This mitigates the issue described in
479             // <https://internals.rust-lang.org/t/surprising-soundness-trouble-around-pollfn/17484>
480             let mut futures = &mut futures;
481 
482             $crate::macros::support::poll_fn(|cx| {
483                 // Track if any branch returns pending. If no branch completes
484                 // **or** returns pending, this implies that all branches are
485                 // disabled.
486                 let mut is_pending = false;
487 
488                 // Choose a starting index to begin polling the futures at. In
489                 // practice, this will either be a pseudo-randomly generated
490                 // number by default, or the constant 0 if `biased;` is
491                 // supplied.
492                 let start = $start;
493 
494                 for i in 0..BRANCHES {
495                     let branch;
496                     #[allow(clippy::modulo_one)]
497                     {
498                         branch = (start + i) % BRANCHES;
499                     }
500                     match branch {
501                         $(
502                             #[allow(unreachable_code)]
503                             $crate::count!( $($skip)* ) => {
504                                 // First, if the future has previously been
505                                 // disabled, do not poll it again. This is done
506                                 // by checking the associated bit in the
507                                 // `disabled` bit field.
508                                 let mask = 1 << branch;
509 
510                                 if disabled & mask == mask {
511                                     // The future has been disabled.
512                                     continue;
513                                 }
514 
515                                 // Extract the future for this branch from the
516                                 // tuple
517                                 let ( $($skip,)* fut, .. ) = &mut *futures;
518 
519                                 // Safety: future is stored on the stack above
520                                 // and never moved.
521                                 let mut fut = unsafe { Pin::new_unchecked(fut) };
522 
523                                 // Try polling it
524                                 let out = match Future::poll(fut, cx) {
525                                     Ready(out) => out,
526                                     Pending => {
527                                         // Track that at least one future is
528                                         // still pending and continue polling.
529                                         is_pending = true;
530                                         continue;
531                                     }
532                                 };
533 
534                                 // Disable the future from future polling.
535                                 disabled |= mask;
536 
537                                 // The future returned a value, check if matches
538                                 // the specified pattern.
539                                 #[allow(unused_variables)]
540                                 #[allow(unused_mut)]
541                                 match &out {
542                                     $crate::select_priv_clean_pattern!($bind) => {}
543                                     _ => continue,
544                                 }
545 
546                                 // The select is complete, return the value
547                                 return Ready($crate::select_variant!(__tokio_select_util::Out, ($($skip)*))(out));
548                             }
549                         )*
550                         _ => unreachable!("reaching this means there probably is an off by one bug"),
551                     }
552                 }
553 
554                 if is_pending {
555                     Pending
556                 } else {
557                     // All branches have been disabled.
558                     Ready(__tokio_select_util::Out::Disabled)
559                 }
560             }).await
561         };
562 
563         match output {
564             $(
565                 $crate::select_variant!(__tokio_select_util::Out, ($($skip)*) ($bind)) => $handle,
566             )*
567             __tokio_select_util::Out::Disabled => $else,
568             _ => unreachable!("failed to match bind"),
569         }
570     }};
571 
572     // ==== Normalize =====
573 
574     // These rules match a single `select!` branch and normalize it for
575     // processing by the first rule.
576 
577     (@ { start=$start:expr; $($t:tt)* } ) => {
578         // No `else` branch
579         $crate::select!(@{ start=$start; $($t)*; panic!("all branches are disabled and there is no else branch") })
580     };
581     (@ { start=$start:expr; $($t:tt)* } else => $else:expr $(,)?) => {
582         $crate::select!(@{ start=$start; $($t)*; $else })
583     };
584     (@ { start=$start:expr; ( $($s:tt)* ) $($t:tt)* } $p:pat = $f:expr, if $c:expr => $h:block, $($r:tt)* ) => {
585         $crate::select!(@{ start=$start; ($($s)* _) $($t)* ($($s)*) $p = $f, if $c => $h, } $($r)*)
586     };
587     (@ { start=$start:expr; ( $($s:tt)* ) $($t:tt)* } $p:pat = $f:expr => $h:block, $($r:tt)* ) => {
588         $crate::select!(@{ start=$start; ($($s)* _) $($t)* ($($s)*) $p = $f, if true => $h, } $($r)*)
589     };
590     (@ { start=$start:expr; ( $($s:tt)* ) $($t:tt)* } $p:pat = $f:expr, if $c:expr => $h:block $($r:tt)* ) => {
591         $crate::select!(@{ start=$start; ($($s)* _) $($t)* ($($s)*) $p = $f, if $c => $h, } $($r)*)
592     };
593     (@ { start=$start:expr; ( $($s:tt)* ) $($t:tt)* } $p:pat = $f:expr => $h:block $($r:tt)* ) => {
594         $crate::select!(@{ start=$start; ($($s)* _) $($t)* ($($s)*) $p = $f, if true => $h, } $($r)*)
595     };
596     (@ { start=$start:expr; ( $($s:tt)* ) $($t:tt)* } $p:pat = $f:expr, if $c:expr => $h:expr ) => {
597         $crate::select!(@{ start=$start; ($($s)* _) $($t)* ($($s)*) $p = $f, if $c => $h, })
598     };
599     (@ { start=$start:expr; ( $($s:tt)* ) $($t:tt)* } $p:pat = $f:expr => $h:expr ) => {
600         $crate::select!(@{ start=$start; ($($s)* _) $($t)* ($($s)*) $p = $f, if true => $h, })
601     };
602     (@ { start=$start:expr; ( $($s:tt)* ) $($t:tt)* } $p:pat = $f:expr, if $c:expr => $h:expr, $($r:tt)* ) => {
603         $crate::select!(@{ start=$start; ($($s)* _) $($t)* ($($s)*) $p = $f, if $c => $h, } $($r)*)
604     };
605     (@ { start=$start:expr; ( $($s:tt)* ) $($t:tt)* } $p:pat = $f:expr => $h:expr, $($r:tt)* ) => {
606         $crate::select!(@{ start=$start; ($($s)* _) $($t)* ($($s)*) $p = $f, if true => $h, } $($r)*)
607     };
608 
609     // ===== Entry point =====
610 
611     (biased; $p:pat = $($t:tt)* ) => {
612         $crate::select!(@{ start=0; () } $p = $($t)*)
613     };
614 
615     ( $p:pat = $($t:tt)* ) => {
616         // Randomly generate a starting point. This makes `select!` a bit more
617         // fair and avoids always polling the first future.
618         $crate::select!(@{ start={ $crate::macros::support::thread_rng_n(BRANCHES) }; () } $p = $($t)*)
619     };
620     () => {
621         compile_error!("select! requires at least one branch.")
622     };
623 }
624 
625 // And here... we manually list out matches for up to 64 branches... I'm not
626 // happy about it either, but this is how we manage to use a declarative macro!
627 
628 #[macro_export]
629 #[doc(hidden)]
630 macro_rules! count {
631     () => {
632         0
633     };
634     (_) => {
635         1
636     };
637     (_ _) => {
638         2
639     };
640     (_ _ _) => {
641         3
642     };
643     (_ _ _ _) => {
644         4
645     };
646     (_ _ _ _ _) => {
647         5
648     };
649     (_ _ _ _ _ _) => {
650         6
651     };
652     (_ _ _ _ _ _ _) => {
653         7
654     };
655     (_ _ _ _ _ _ _ _) => {
656         8
657     };
658     (_ _ _ _ _ _ _ _ _) => {
659         9
660     };
661     (_ _ _ _ _ _ _ _ _ _) => {
662         10
663     };
664     (_ _ _ _ _ _ _ _ _ _ _) => {
665         11
666     };
667     (_ _ _ _ _ _ _ _ _ _ _ _) => {
668         12
669     };
670     (_ _ _ _ _ _ _ _ _ _ _ _ _) => {
671         13
672     };
673     (_ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
674         14
675     };
676     (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
677         15
678     };
679     (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
680         16
681     };
682     (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
683         17
684     };
685     (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
686         18
687     };
688     (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
689         19
690     };
691     (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
692         20
693     };
694     (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
695         21
696     };
697     (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
698         22
699     };
700     (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
701         23
702     };
703     (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
704         24
705     };
706     (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
707         25
708     };
709     (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
710         26
711     };
712     (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
713         27
714     };
715     (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
716         28
717     };
718     (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
719         29
720     };
721     (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
722         30
723     };
724     (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
725         31
726     };
727     (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
728         32
729     };
730     (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
731         33
732     };
733     (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
734         34
735     };
736     (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
737         35
738     };
739     (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
740         36
741     };
742     (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
743         37
744     };
745     (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
746         38
747     };
748     (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
749         39
750     };
751     (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
752         40
753     };
754     (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
755         41
756     };
757     (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
758         42
759     };
760     (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
761         43
762     };
763     (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
764         44
765     };
766     (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
767         45
768     };
769     (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
770         46
771     };
772     (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
773         47
774     };
775     (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
776         48
777     };
778     (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
779         49
780     };
781     (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
782         50
783     };
784     (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
785         51
786     };
787     (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
788         52
789     };
790     (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
791         53
792     };
793     (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
794         54
795     };
796     (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
797         55
798     };
799     (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
800         56
801     };
802     (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
803         57
804     };
805     (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
806         58
807     };
808     (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
809         59
810     };
811     (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
812         60
813     };
814     (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
815         61
816     };
817     (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
818         62
819     };
820     (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
821         63
822     };
823     (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
824         64
825     };
826 }
827 
828 #[macro_export]
829 #[doc(hidden)]
830 macro_rules! select_variant {
831     ($($p:ident)::*, () $($t:tt)*) => {
832         $($p)::*::_0 $($t)*
833     };
834     ($($p:ident)::*, (_) $($t:tt)*) => {
835         $($p)::*::_1 $($t)*
836     };
837     ($($p:ident)::*, (_ _) $($t:tt)*) => {
838         $($p)::*::_2 $($t)*
839     };
840     ($($p:ident)::*, (_ _ _) $($t:tt)*) => {
841         $($p)::*::_3 $($t)*
842     };
843     ($($p:ident)::*, (_ _ _ _) $($t:tt)*) => {
844         $($p)::*::_4 $($t)*
845     };
846     ($($p:ident)::*, (_ _ _ _ _) $($t:tt)*) => {
847         $($p)::*::_5 $($t)*
848     };
849     ($($p:ident)::*, (_ _ _ _ _ _) $($t:tt)*) => {
850         $($p)::*::_6 $($t)*
851     };
852     ($($p:ident)::*, (_ _ _ _ _ _ _) $($t:tt)*) => {
853         $($p)::*::_7 $($t)*
854     };
855     ($($p:ident)::*, (_ _ _ _ _ _ _ _) $($t:tt)*) => {
856         $($p)::*::_8 $($t)*
857     };
858     ($($p:ident)::*, (_ _ _ _ _ _ _ _ _) $($t:tt)*) => {
859         $($p)::*::_9 $($t)*
860     };
861     ($($p:ident)::*, (_ _ _ _ _ _ _ _ _ _) $($t:tt)*) => {
862         $($p)::*::_10 $($t)*
863     };
864     ($($p:ident)::*, (_ _ _ _ _ _ _ _ _ _ _) $($t:tt)*) => {
865         $($p)::*::_11 $($t)*
866     };
867     ($($p:ident)::*, (_ _ _ _ _ _ _ _ _ _ _ _) $($t:tt)*) => {
868         $($p)::*::_12 $($t)*
869     };
870     ($($p:ident)::*, (_ _ _ _ _ _ _ _ _ _ _ _ _) $($t:tt)*) => {
871         $($p)::*::_13 $($t)*
872     };
873     ($($p:ident)::*, (_ _ _ _ _ _ _ _ _ _ _ _ _ _) $($t:tt)*) => {
874         $($p)::*::_14 $($t)*
875     };
876     ($($p:ident)::*, (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _) $($t:tt)*) => {
877         $($p)::*::_15 $($t)*
878     };
879     ($($p:ident)::*, (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) $($t:tt)*) => {
880         $($p)::*::_16 $($t)*
881     };
882     ($($p:ident)::*, (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) $($t:tt)*) => {
883         $($p)::*::_17 $($t)*
884     };
885     ($($p:ident)::*, (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) $($t:tt)*) => {
886         $($p)::*::_18 $($t)*
887     };
888     ($($p:ident)::*, (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) $($t:tt)*) => {
889         $($p)::*::_19 $($t)*
890     };
891     ($($p:ident)::*, (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) $($t:tt)*) => {
892         $($p)::*::_20 $($t)*
893     };
894     ($($p:ident)::*, (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) $($t:tt)*) => {
895         $($p)::*::_21 $($t)*
896     };
897     ($($p:ident)::*, (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) $($t:tt)*) => {
898         $($p)::*::_22 $($t)*
899     };
900     ($($p:ident)::*, (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) $($t:tt)*) => {
901         $($p)::*::_23 $($t)*
902     };
903     ($($p:ident)::*, (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) $($t:tt)*) => {
904         $($p)::*::_24 $($t)*
905     };
906     ($($p:ident)::*, (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) $($t:tt)*) => {
907         $($p)::*::_25 $($t)*
908     };
909     ($($p:ident)::*, (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) $($t:tt)*) => {
910         $($p)::*::_26 $($t)*
911     };
912     ($($p:ident)::*, (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) $($t:tt)*) => {
913         $($p)::*::_27 $($t)*
914     };
915     ($($p:ident)::*, (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) $($t:tt)*) => {
916         $($p)::*::_28 $($t)*
917     };
918     ($($p:ident)::*, (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) $($t:tt)*) => {
919         $($p)::*::_29 $($t)*
920     };
921     ($($p:ident)::*, (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) $($t:tt)*) => {
922         $($p)::*::_30 $($t)*
923     };
924     ($($p:ident)::*, (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) $($t:tt)*) => {
925         $($p)::*::_31 $($t)*
926     };
927     ($($p:ident)::*, (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) $($t:tt)*) => {
928         $($p)::*::_32 $($t)*
929     };
930     ($($p:ident)::*, (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) $($t:tt)*) => {
931         $($p)::*::_33 $($t)*
932     };
933     ($($p:ident)::*, (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) $($t:tt)*) => {
934         $($p)::*::_34 $($t)*
935     };
936     ($($p:ident)::*, (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) $($t:tt)*) => {
937         $($p)::*::_35 $($t)*
938     };
939     ($($p:ident)::*, (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) $($t:tt)*) => {
940         $($p)::*::_36 $($t)*
941     };
942     ($($p:ident)::*, (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) $($t:tt)*) => {
943         $($p)::*::_37 $($t)*
944     };
945     ($($p:ident)::*, (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) $($t:tt)*) => {
946         $($p)::*::_38 $($t)*
947     };
948     ($($p:ident)::*, (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) $($t:tt)*) => {
949         $($p)::*::_39 $($t)*
950     };
951     ($($p:ident)::*, (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) $($t:tt)*) => {
952         $($p)::*::_40 $($t)*
953     };
954     ($($p:ident)::*, (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) $($t:tt)*) => {
955         $($p)::*::_41 $($t)*
956     };
957     ($($p:ident)::*, (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) $($t:tt)*) => {
958         $($p)::*::_42 $($t)*
959     };
960     ($($p:ident)::*, (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) $($t:tt)*) => {
961         $($p)::*::_43 $($t)*
962     };
963     ($($p:ident)::*, (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) $($t:tt)*) => {
964         $($p)::*::_44 $($t)*
965     };
966     ($($p:ident)::*, (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) $($t:tt)*) => {
967         $($p)::*::_45 $($t)*
968     };
969     ($($p:ident)::*, (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) $($t:tt)*) => {
970         $($p)::*::_46 $($t)*
971     };
972     ($($p:ident)::*, (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) $($t:tt)*) => {
973         $($p)::*::_47 $($t)*
974     };
975     ($($p:ident)::*, (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) $($t:tt)*) => {
976         $($p)::*::_48 $($t)*
977     };
978     ($($p:ident)::*, (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) $($t:tt)*) => {
979         $($p)::*::_49 $($t)*
980     };
981     ($($p:ident)::*, (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) $($t:tt)*) => {
982         $($p)::*::_50 $($t)*
983     };
984     ($($p:ident)::*, (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) $($t:tt)*) => {
985         $($p)::*::_51 $($t)*
986     };
987     ($($p:ident)::*, (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) $($t:tt)*) => {
988         $($p)::*::_52 $($t)*
989     };
990     ($($p:ident)::*, (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) $($t:tt)*) => {
991         $($p)::*::_53 $($t)*
992     };
993     ($($p:ident)::*, (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) $($t:tt)*) => {
994         $($p)::*::_54 $($t)*
995     };
996     ($($p:ident)::*, (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) $($t:tt)*) => {
997         $($p)::*::_55 $($t)*
998     };
999     ($($p:ident)::*, (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) $($t:tt)*) => {
1000         $($p)::*::_56 $($t)*
1001     };
1002     ($($p:ident)::*, (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) $($t:tt)*) => {
1003         $($p)::*::_57 $($t)*
1004     };
1005     ($($p:ident)::*, (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) $($t:tt)*) => {
1006         $($p)::*::_58 $($t)*
1007     };
1008     ($($p:ident)::*, (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) $($t:tt)*) => {
1009         $($p)::*::_59 $($t)*
1010     };
1011     ($($p:ident)::*, (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) $($t:tt)*) => {
1012         $($p)::*::_60 $($t)*
1013     };
1014     ($($p:ident)::*, (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) $($t:tt)*) => {
1015         $($p)::*::_61 $($t)*
1016     };
1017     ($($p:ident)::*, (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) $($t:tt)*) => {
1018         $($p)::*::_62 $($t)*
1019     };
1020     ($($p:ident)::*, (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) $($t:tt)*) => {
1021         $($p)::*::_63 $($t)*
1022     };
1023 }
1024