Skip to main content

tokio/macros/
select.rs

1macro_rules! doc {
2    ($select:item) => {
3        /// Waits on multiple concurrent branches, returning when the **first** branch
4        /// completes, cancelling the remaining branches.
5        ///
6        /// The `select!` macro must be used inside of async functions, closures, and
7        /// blocks.
8        ///
9        /// The `select!` macro accepts one or more branches with the following pattern:
10        ///
11        /// ```text
12        /// <pattern> = <async expression> (, if <precondition>)? => <handler>,
13        /// ```
14        ///
15        /// Additionally, the `select!` macro may include a single, optional `else`
16        /// branch, which evaluates if none of the other branches match their patterns:
17        ///
18        /// ```text
19        /// else => <expression>
20        /// ```
21        ///
22        /// The macro aggregates all `<async expression>` expressions and runs them
23        /// concurrently on the **current** task. Once the **first** expression
24        /// completes with a value that matches its `<pattern>`, the `select!` macro
25        /// returns the result of evaluating the completed branch's `<handler>`
26        /// expression.
27        ///
28        /// Additionally, each branch may include an optional `if` precondition. If the
29        /// precondition returns `false`, then the branch is disabled. The provided
30        /// `<async expression>` is still evaluated but the resulting future is never
31        /// polled. This capability is useful when using `select!` within a loop.
32        ///
33        /// The complete lifecycle of a `select!` expression is as follows:
34        ///
35        /// 1. Evaluate all provided `<precondition>` expressions. If the precondition
36        ///    returns `false`, disable the branch for the remainder of the current call
37        ///    to `select!`. Re-entering `select!` due to a loop clears the "disabled"
38        ///    state.
39        /// 2. Aggregate the `<async expression>`s from each branch, including the
40        ///    disabled ones. If the branch is disabled, `<async expression>` is still
41        ///    evaluated, but the resulting future is not polled.
42        /// 3. If **all** branches are disabled: go to step 6.
43        /// 4. Concurrently await on the results for all remaining `<async expression>`s.
44        /// 5. Once an `<async expression>` returns a value, attempt to apply the value to the
45        ///    provided `<pattern>`. If the pattern matches, evaluate the `<handler>` and return.
46        ///    If the pattern **does not** match, disable the current branch for the remainder of
47        ///    the current call to `select!`. Continue from step 3.
48        /// 6. Evaluate the `else` expression. If no else expression is provided, panic.
49        ///
50        /// # Runtime characteristics
51        ///
52        /// By running all async expressions on the current task, the expressions are
53        /// able to run **concurrently** but not in **parallel**. This means all
54        /// expressions are run on the same thread and if one branch blocks the thread,
55        /// all other expressions will be unable to continue. If parallelism is
56        /// required, spawn each async expression using [`tokio::spawn`] and pass the
57        /// join handle to `select!`.
58        ///
59        /// [`tokio::spawn`]: crate::spawn
60        ///
61        /// # Fairness
62        ///
63        /// By default, `select!` randomly picks a branch to check first. This provides
64        /// some level of fairness when calling `select!` in a loop with branches that
65        /// are always ready.
66        ///
67        /// This behavior can be overridden by adding `biased;` to the beginning of the
68        /// macro usage. See the examples for details. This will cause `select` to poll
69        /// the futures in the order they appear from top to bottom. There are a few
70        /// reasons you may want this:
71        ///
72        /// - The random number generation of `tokio::select!` has a non-zero CPU cost
73        /// - Your futures may interact in a way where known polling order is significant
74        ///
75        /// But there is an important caveat to this mode. It becomes your responsibility
76        /// to ensure that the polling order of your futures is fair. If for example you
77        /// are selecting between a stream and a shutdown future, and the stream has a
78        /// huge volume of messages and zero or nearly zero time between them, you should
79        /// place the shutdown future earlier in the `select!` list to ensure that it is
80        /// always polled, and will not be ignored due to the stream being constantly
81        /// ready.
82        ///
83        /// # Panics
84        ///
85        /// The `select!` macro panics if all branches are disabled **and** there is no
86        /// provided `else` branch. A branch is disabled when the provided `if`
87        /// precondition returns `false` **or** when the pattern does not match the
88        /// result of `<async expression>`.
89        ///
90        /// # Cancellation safety
91        ///
92        /// When using `select!` in a loop to receive messages from multiple sources,
93        /// you should make sure that the receive call is cancellation safe to avoid
94        /// losing messages. This section goes through various common methods and
95        /// describes whether they are cancel safe.  The lists in this section are not
96        /// exhaustive.
97        ///
98        /// Cancellation safety describes what happens when a future is dropped
99        /// before it completes. Whether something is cancellation safe depends on
100        /// the behavior of the future passed to `select!`, which may come from an
101        /// async method, an async expression, or another future-producing operation.
102        ///
103        /// The following methods are cancellation safe:
104        ///
105        ///  * [`tokio::sync::mpsc::Receiver::recv`](crate::sync::mpsc::Receiver::recv)
106        ///  * [`tokio::sync::mpsc::UnboundedReceiver::recv`](crate::sync::mpsc::UnboundedReceiver::recv)
107        ///  * [`tokio::sync::broadcast::Receiver::recv`](crate::sync::broadcast::Receiver::recv)
108        ///  * [`tokio::sync::watch::Receiver::changed`](crate::sync::watch::Receiver::changed)
109        ///  * [`tokio::net::TcpListener::accept`](crate::net::TcpListener::accept)
110        ///  * [`tokio::net::UnixListener::accept`](crate::net::UnixListener::accept)
111        ///  * [`tokio::signal::unix::Signal::recv`](crate::signal::unix::Signal::recv)
112        ///  * [`tokio::io::AsyncReadExt::read`](crate::io::AsyncReadExt::read) on any `AsyncRead`
113        ///  * [`tokio::io::AsyncReadExt::read_buf`](crate::io::AsyncReadExt::read_buf) on any `AsyncRead`
114        ///  * [`tokio::io::AsyncWriteExt::write`](crate::io::AsyncWriteExt::write) on any `AsyncWrite`
115        ///  * [`tokio::io::AsyncWriteExt::write_buf`](crate::io::AsyncWriteExt::write_buf) on any `AsyncWrite`
116        ///  * [`tokio_stream::StreamExt::next`](https://docs.rs/tokio-stream/0.1/tokio_stream/trait.StreamExt.html#method.next) on any `Stream`
117        ///  * [`futures::stream::StreamExt::next`](https://docs.rs/futures/0.3/futures/stream/trait.StreamExt.html#method.next) on any `Stream`
118        ///
119        /// The following methods are not cancellation safe and can lead to loss of data:
120        ///
121        ///  * [`tokio::io::AsyncReadExt::read_exact`](crate::io::AsyncReadExt::read_exact)
122        ///  * [`tokio::io::AsyncReadExt::read_to_end`](crate::io::AsyncReadExt::read_to_end)
123        ///  * [`tokio::io::AsyncReadExt::read_to_string`](crate::io::AsyncReadExt::read_to_string)
124        ///  * [`tokio::io::AsyncWriteExt::write_all`](crate::io::AsyncWriteExt::write_all)
125        ///
126        /// The following methods are not cancellation safe because they use a queue for
127        /// fairness and cancellation makes you lose your place in the queue:
128        ///
129        ///  * [`tokio::sync::Mutex::lock`](crate::sync::Mutex::lock)
130        ///  * [`tokio::sync::RwLock::read`](crate::sync::RwLock::read)
131        ///  * [`tokio::sync::RwLock::write`](crate::sync::RwLock::write)
132        ///  * [`tokio::sync::Semaphore::acquire`](crate::sync::Semaphore::acquire)
133        ///  * [`tokio::sync::Notify::notified`](crate::sync::Notify::notified)
134        ///
135        /// To determine whether your own methods are cancellation safe, look for the
136        /// location of uses of `.await`. This is because when an asynchronous method is
137        /// cancelled, that always happens at an `.await`. If your function behaves
138        /// correctly even if it is restarted while waiting at an `.await`, then it is
139        /// cancellation safe.
140        ///
141        /// Cancellation safety can be defined in the following way: If you have a
142        /// future that has not yet completed, then it must be a no-op to drop that
143        /// future and recreate it. This definition is motivated by the situation where
144        /// a `select!` is used in a loop. Without this guarantee, you would lose your
145        /// progress when another branch completes and you restart the `select!` by
146        /// going around the loop.
147        ///
148        /// Be aware that cancelling something that is not cancellation safe is not
149        /// necessarily wrong. For example, if you are cancelling a task because the
150        /// application is shutting down, then you probably don't care that partially
151        /// read data is lost.
152        ///
153        /// # Examples
154        ///
155        /// Basic select with two branches.
156        ///
157        /// ```
158        /// async fn do_stuff_async() {
159        ///     // async work
160        /// }
161        ///
162        /// async fn more_async_work() {
163        ///     // more here
164        /// }
165        ///
166        /// # #[tokio::main(flavor = "current_thread")]
167        /// # async fn main() {
168        /// tokio::select! {
169        ///     _ = do_stuff_async() => {
170        ///         println!("do_stuff_async() completed first")
171        ///     }
172        ///     _ = more_async_work() => {
173        ///         println!("more_async_work() completed first")
174        ///     }
175        /// };
176        /// # }
177        /// ```
178        ///
179        /// Basic stream selecting.
180        ///
181        /// ```
182        /// use tokio_stream::{self as stream, StreamExt};
183        ///
184        /// # #[tokio::main(flavor = "current_thread")]
185        /// # async fn main() {
186        /// let mut stream1 = stream::iter(vec![1, 2, 3]);
187        /// let mut stream2 = stream::iter(vec![4, 5, 6]);
188        ///
189        /// let next = tokio::select! {
190        ///     v = stream1.next() => v.unwrap(),
191        ///     v = stream2.next() => v.unwrap(),
192        /// };
193        ///
194        /// assert!(next == 1 || next == 4);
195        /// # }
196        /// ```
197        ///
198        /// Collect the contents of two streams. In this example, we rely on pattern
199        /// matching and the fact that `stream::iter` is "fused", i.e. once the stream
200        /// is complete, all calls to `next()` return `None`.
201        ///
202        /// ```
203        /// use tokio_stream::{self as stream, StreamExt};
204        ///
205        /// # #[tokio::main(flavor = "current_thread")]
206        /// # async fn main() {
207        /// let mut stream1 = stream::iter(vec![1, 2, 3]);
208        /// let mut stream2 = stream::iter(vec![4, 5, 6]);
209        ///
210        /// let mut values = vec![];
211        ///
212        /// loop {
213        ///     tokio::select! {
214        ///         Some(v) = stream1.next() => values.push(v),
215        ///         Some(v) = stream2.next() => values.push(v),
216        ///         else => break,
217        ///     }
218        /// }
219        ///
220        /// values.sort();
221        /// assert_eq!(&[1, 2, 3, 4, 5, 6], &values[..]);
222        /// # }
223        /// ```
224        ///
225        /// Using the same future in multiple `select!` expressions can be done by passing
226        /// a reference to the future. Doing so requires the future to be [`Unpin`]. A
227        /// future can be made [`Unpin`] by either using [`Box::pin`] or stack pinning.
228        ///
229        /// [`Unpin`]: std::marker::Unpin
230        /// [`Box::pin`]: std::boxed::Box::pin
231        ///
232        /// Here, a stream is consumed for at most 1 second.
233        ///
234        /// ```
235        /// use tokio_stream::{self as stream, StreamExt};
236        /// use tokio::time::{self, Duration};
237        ///
238        /// # #[tokio::main(flavor = "current_thread")]
239        /// # async fn main() {
240        /// let mut stream = stream::iter(vec![1, 2, 3]);
241        /// let sleep = time::sleep(Duration::from_secs(1));
242        /// tokio::pin!(sleep);
243        ///
244        /// loop {
245        ///     tokio::select! {
246        ///         maybe_v = stream.next() => {
247        ///             if let Some(v) = maybe_v {
248        ///                 println!("got = {}", v);
249        ///             } else {
250        ///                 break;
251        ///             }
252        ///         }
253        ///         _ = &mut sleep => {
254        ///             println!("timeout");
255        ///             break;
256        ///         }
257        ///     }
258        /// }
259        /// # }
260        /// ```
261        ///
262        /// Joining two values using `select!`.
263        ///
264        /// ```
265        /// use tokio::sync::oneshot;
266        ///
267        /// # #[tokio::main(flavor = "current_thread")]
268        /// # async fn main() {
269        /// let (tx1, mut rx1) = oneshot::channel();
270        /// let (tx2, mut rx2) = oneshot::channel();
271        ///
272        /// tokio::spawn(async move {
273        ///     tx1.send("first").unwrap();
274        /// });
275        ///
276        /// tokio::spawn(async move {
277        ///     tx2.send("second").unwrap();
278        /// });
279        ///
280        /// let mut a = None;
281        /// let mut b = None;
282        ///
283        /// while a.is_none() || b.is_none() {
284        ///     tokio::select! {
285        ///         v1 = (&mut rx1), if a.is_none() => a = Some(v1.unwrap()),
286        ///         v2 = (&mut rx2), if b.is_none() => b = Some(v2.unwrap()),
287        ///     }
288        /// }
289        ///
290        /// let res = (a.unwrap(), b.unwrap());
291        ///
292        /// assert_eq!(res.0, "first");
293        /// assert_eq!(res.1, "second");
294        /// # }
295        /// ```
296        ///
297        /// Using the `biased;` mode to control polling order.
298        ///
299        /// ```
300        /// # #[tokio::main(flavor = "current_thread")]
301        /// # async fn main() {
302        /// let mut count = 0u8;
303        ///
304        /// loop {
305        ///     tokio::select! {
306        ///         // If you run this example without `biased;`, the polling order is
307        ///         // pseudo-random, and the assertions on the value of count will
308        ///         // (probably) fail.
309        ///         biased;
310        ///
311        ///         _ = async {}, if count < 1 => {
312        ///             count += 1;
313        ///             assert_eq!(count, 1);
314        ///         }
315        ///         _ = async {}, if count < 2 => {
316        ///             count += 1;
317        ///             assert_eq!(count, 2);
318        ///         }
319        ///         _ = async {}, if count < 3 => {
320        ///             count += 1;
321        ///             assert_eq!(count, 3);
322        ///         }
323        ///         _ = async {}, if count < 4 => {
324        ///             count += 1;
325        ///             assert_eq!(count, 4);
326        ///         }
327        ///
328        ///         else => {
329        ///             break;
330        ///         }
331        ///     };
332        /// }
333        /// # }
334        /// ```
335        ///
336        /// ## Avoid racy `if` preconditions
337        ///
338        /// Given that `if` preconditions are used to disable `select!` branches, some
339        /// caution must be used to avoid missing values.
340        ///
341        /// For example, here is **incorrect** usage of `sleep` with `if`. The objective
342        /// is to repeatedly run an asynchronous task for up to 50 milliseconds.
343        /// However, there is a potential for the `sleep` completion to be missed.
344        ///
345        /// ```no_run,should_panic
346        /// use tokio::time::{self, Duration};
347        ///
348        /// async fn some_async_work() {
349        ///     // do work
350        /// }
351        ///
352        /// # #[tokio::main(flavor = "current_thread")]
353        /// # async fn main() {
354        /// let sleep = time::sleep(Duration::from_millis(50));
355        /// tokio::pin!(sleep);
356        ///
357        /// while !sleep.is_elapsed() {
358        ///     tokio::select! {
359        ///         _ = &mut sleep, if !sleep.is_elapsed() => {
360        ///             println!("operation timed out");
361        ///         }
362        ///         _ = some_async_work() => {
363        ///             println!("operation completed");
364        ///         }
365        ///     }
366        /// }
367        ///
368        /// panic!("This example shows how not to do it!");
369        /// # }
370        /// ```
371        ///
372        /// In the above example, `sleep.is_elapsed()` may return `true` even if
373        /// `sleep.poll()` never returned `Ready`. This opens up a potential race
374        /// condition where `sleep` expires between the `while !sleep.is_elapsed()`
375        /// check and the call to `select!` resulting in the `some_async_work()` call to
376        /// run uninterrupted despite the sleep having elapsed.
377        ///
378        /// One way to write the above example without the race would be:
379        ///
380        /// ```
381        /// use tokio::time::{self, Duration};
382        ///
383        /// async fn some_async_work() {
384        /// # time::sleep(Duration::from_millis(10)).await;
385        ///     // do work
386        /// }
387        ///
388        /// # #[tokio::main(flavor = "current_thread")]
389        /// # async fn main() {
390        /// let sleep = time::sleep(Duration::from_millis(50));
391        /// tokio::pin!(sleep);
392        ///
393        /// loop {
394        ///     tokio::select! {
395        ///         _ = &mut sleep => {
396        ///             println!("operation timed out");
397        ///             break;
398        ///         }
399        ///         _ = some_async_work() => {
400        ///             println!("operation completed");
401        ///         }
402        ///     }
403        /// }
404        /// # }
405        /// ```
406        /// # Alternatives from the Ecosystem
407        ///
408        /// The `select!` macro is a powerful tool for managing multiple asynchronous
409        /// branches, enabling tasks to run concurrently within the same thread. However,
410        /// its use can introduce challenges, particularly around cancellation safety, which
411        /// can lead to subtle and hard-to-debug errors. For many use cases, ecosystem
412        /// alternatives may be preferable as they mitigate these concerns by offering
413        /// clearer syntax, more predictable control flow, and reducing the need to manually
414        /// handle issues like fuse semantics or cancellation safety.
415        ///
416        /// ## Merging Streams
417        ///
418        /// For cases where `loop { select! { ... } }` is used to poll multiple tasks,
419        /// stream merging offers a concise alternative, inherently handle cancellation-safe
420        /// processing, removing the risk of data loss. Libraries such as [`tokio_stream`],
421        /// [`futures::stream`] and [`futures_concurrency`] provide tools for merging
422        /// streams and handling their outputs sequentially.
423        ///
424        /// [`tokio_stream`]: https://docs.rs/tokio-stream/latest/tokio_stream/
425        /// [`futures::stream`]: https://docs.rs/futures/latest/futures/stream/
426        /// [`futures_concurrency`]: https://docs.rs/futures-concurrency/latest/futures_concurrency/
427        ///
428        /// ### Example with `select!`
429        ///
430        /// ```
431        /// struct File;
432        /// struct Channel;
433        /// struct Socket;
434        ///
435        /// impl Socket {
436        ///     async fn read_packet(&mut self) -> Vec<u8> {
437        ///         vec![]
438        ///     }
439        /// }
440        ///
441        /// async fn read_send(_file: &mut File, _channel: &mut Channel) {
442        ///     // do work that is not cancel safe
443        /// }
444        ///
445        /// # #[tokio::main(flavor = "current_thread")]
446        /// # async fn main() {
447        /// // open our IO types
448        /// let mut file = File;
449        /// let mut channel = Channel;
450        /// let mut socket = Socket;
451        ///
452        /// loop {
453        ///     tokio::select! {
454        ///         _ = read_send(&mut file, &mut channel) => { /* ... */ },
455        ///         _data = socket.read_packet() => { /* ... */ }
456        ///         _ = futures::future::ready(()) => break
457        ///     }
458        /// }
459        /// # }
460        /// ```
461        ///
462        /// ### Moving to `merge`
463        ///
464        /// By using merge, you can unify multiple asynchronous tasks into a single stream,
465        /// eliminating the need to manage tasks manually and reducing the risk of
466        /// unintended behavior like data loss.
467        ///
468        /// ```
469        /// use std::pin::pin;
470        ///
471        /// use futures::stream::unfold;
472        /// use tokio_stream::StreamExt;
473        ///
474        /// struct File;
475        /// struct Channel;
476        /// struct Socket;
477        ///
478        /// impl Socket {
479        ///     async fn read_packet(&mut self) -> Vec<u8> {
480        ///         vec![]
481        ///     }
482        /// }
483        ///
484        /// async fn read_send(_file: &mut File, _channel: &mut Channel) {
485        ///     // do work that is not cancel safe
486        /// }
487        ///
488        /// enum Message {
489        ///     Stop,
490        ///     Sent,
491        ///     Data(Vec<u8>),
492        /// }
493        ///
494        /// # #[tokio::main(flavor = "current_thread")]
495        /// # async fn main() {
496        /// // open our IO types
497        /// let file = File;
498        /// let channel = Channel;
499        /// let socket = Socket;
500        ///
501        /// let a = unfold((file, channel), |(mut file, mut channel)| async {
502        ///     read_send(&mut file, &mut channel).await;
503        ///     Some((Message::Sent, (file, channel)))
504        /// });
505        /// let b = unfold(socket, |mut socket| async {
506        ///     let data = socket.read_packet().await;
507        ///     Some((Message::Data(data), socket))
508        /// });
509        /// let c = tokio_stream::iter([Message::Stop]);
510        ///
511        /// let mut s = pin!(a.merge(b).merge(c));
512        /// while let Some(msg) = s.next().await {
513        ///     match msg {
514        ///         Message::Data(_data) => { /* ... */ }
515        ///         Message::Sent => continue,
516        ///         Message::Stop => break,
517        ///     }
518        /// }
519        /// # }
520        /// ```
521        ///
522        /// ## Racing Futures
523        ///
524        /// If you need to wait for the first completion among several asynchronous tasks,
525        /// ecosystem utilities such as
526        /// [`futures`](https://docs.rs/futures/latest/futures/),
527        /// [`futures-lite`](https://docs.rs/futures-lite/latest/futures_lite/) or
528        /// [`futures-concurrency`](https://docs.rs/futures-concurrency/latest/futures_concurrency/)
529        /// provide streamlined syntax for racing futures:
530        ///
531        /// - [`futures_concurrency::future::Race`](https://docs.rs/futures-concurrency/latest/futures_concurrency/future/trait.Race.html)
532        /// - [`futures::select`](https://docs.rs/futures/latest/futures/macro.select.html)
533        /// - [`futures::stream::select_all`](https://docs.rs/futures/latest/futures/stream/select_all/index.html) (for streams)
534        /// - [`futures_lite::future::or`](https://docs.rs/futures-lite/latest/futures_lite/future/fn.or.html)
535        /// - [`futures_lite::future::race`](https://docs.rs/futures-lite/latest/futures_lite/future/fn.race.html)
536        ///
537        /// ```
538        /// use futures_concurrency::future::Race;
539        ///
540        /// # #[tokio::main(flavor = "current_thread")]
541        /// # async fn main() {
542        /// let task_a = async { Ok("ok") };
543        /// let task_b = async { Err("error") };
544        /// let result = (task_a, task_b).race().await;
545        ///
546        /// match result {
547        ///     Ok(output) => println!("First task completed with: {output}"),
548        ///     Err(err) => eprintln!("Error occurred: {err}"),
549        /// }
550        /// # }
551        /// ```
552        #[macro_export]
553        #[cfg_attr(docsrs, doc(cfg(feature = "macros")))]
554        $select
555    };
556}
557
558#[cfg(doc)]
559doc! {macro_rules! select {
560    {
561        $(
562            biased;
563        )?
564        $(
565            $bind:pat = $fut:expr $(, if $cond:expr)? => $handler:expr,
566        )*
567        $(
568            else => $els:expr $(,)?
569        )?
570    } => {
571        unimplemented!()
572    };
573}}
574
575#[cfg(not(doc))]
576doc! {macro_rules! select {
577    // Uses a declarative macro to do **most** of the work. While it is possible
578    // to implement fully with a declarative macro, a procedural macro is used
579    // to enable improved error messages.
580    //
581    // The macro is structured as a tt-muncher. All branches are processed and
582    // normalized. Once the input is normalized, it is passed to the top-most
583    // rule. When entering the macro, `@{ }` is inserted at the front. This is
584    // used to collect the normalized input.
585    //
586    // The macro only recurses once per branch. This allows using `select!`
587    // without requiring the user to increase the recursion limit.
588
589    // All input is normalized, now transform.
590    (@ {
591        // The index of the future to poll first (in bias mode), or the RNG
592        // expression to use to pick a future to poll first.
593        start=$start:expr;
594
595        // One `_` for each branch in the `select!` macro. Passing this to
596        // `count!` converts $skip to an integer.
597        ( $($count:tt)* )
598
599        // Normalized select branches. `( $skip )` is a set of `_` characters.
600        // There is one `_` for each select branch **before** this one. Given
601        // that all input futures are stored in a tuple, $skip is useful for
602        // generating a pattern to reference the future for the current branch.
603        // $skip is also used as an argument to `count!`, returning the index of
604        // the current select branch.
605        $( ( $($skip:tt)* ) $bind:pat = $fut:expr, if $c:expr => $handle:expr, )+
606
607        // Fallback expression used when all select branches have been disabled.
608        ; $else:expr
609
610    }) => {{
611        // Enter a context where stable "function-like" proc macros can be used.
612        //
613        // This module is defined within a scope and should not leak out of this
614        // macro.
615        #[doc(hidden)]
616        mod __tokio_select_util {
617            // Generate an enum with one variant per select branch
618            $crate::select_priv_declare_output_enum!( ( $($count)* ) );
619        }
620
621        // `tokio::macros::support` is a public, but doc(hidden) module
622        // including a re-export of all types needed by this macro.
623        use $crate::macros::support::Pin;
624
625        const BRANCHES: u32 = $crate::count!( $($count)* );
626
627        let mut disabled: __tokio_select_util::Mask = Default::default();
628
629        // First, invoke all the pre-conditions. For any that return true,
630        // set the appropriate bit in `disabled`.
631        $(
632            if !$c {
633                let mask: __tokio_select_util::Mask = 1 << $crate::count!( $($skip)* );
634                disabled |= mask;
635            }
636        )*
637
638        // Create a scope to separate polling from handling the output. This
639        // adds borrow checker flexibility when using the macro.
640        let mut output = {
641            // Store each future directly first (that is, without wrapping the future in a call to
642            // `IntoFuture::into_future`). This allows the `$fut` expression to make use of
643            // temporary lifetime extension.
644            //
645            // https://doc.rust-lang.org/1.58.1/reference/destructors.html#temporary-lifetime-extension
646            let futures_init = ($( $fut, )+);
647
648            // Safety: Nothing must be moved out of `futures`. This is to
649            // satisfy the requirement of `Pin::new_unchecked` called below.
650            //
651            // We can't use the `pin!` macro for this because `futures` is a
652            // tuple and the standard library provides no way to pin-project to
653            // the fields of a tuple.
654            let mut futures = ($( $crate::macros::support::IntoFuture::into_future(
655                        $crate::count_field!( futures_init.$($skip)* )
656            ),)+);
657
658            // This assignment makes sure that the `poll_fn` closure only has a
659            // reference to the futures, instead of taking ownership of them.
660            // This mitigates the issue described in
661            // <https://internals.rust-lang.org/t/surprising-soundness-trouble-around-pollfn/17484>
662            let mut futures = &mut futures;
663
664            $crate::macros::support::poll_fn(|cx| {
665                // Return `Pending` when the task budget is depleted since budget-aware futures
666                // are going to yield anyway and other futures will not cooperate.
667                $crate::macros::support::ready!($crate::macros::support::poll_budget_available(cx));
668
669                // Track if any branch returns pending. If no branch completes
670                // **or** returns pending, this implies that all branches are
671                // disabled.
672                let mut is_pending = false;
673
674                // Choose a starting index to begin polling the futures at. In
675                // practice, this will either be a pseudo-randomly generated
676                // number by default, or the constant 0 if `biased;` is
677                // supplied.
678                let start = $start;
679
680                for i in 0..BRANCHES {
681                    let branch;
682                    #[allow(clippy::modulo_one)]
683                    {
684                        branch = (start + i) % BRANCHES;
685                    }
686                    match branch {
687                        $(
688                            #[allow(unreachable_code)]
689                            $crate::count!( $($skip)* ) => {
690                                // First, if the future has previously been
691                                // disabled, do not poll it again. This is done
692                                // by checking the associated bit in the
693                                // `disabled` bit field.
694                                let mask = 1 << branch;
695
696                                if disabled & mask == mask {
697                                    // The future has been disabled.
698                                    continue;
699                                }
700
701                                // Extract the future for this branch from the
702                                // tuple
703                                let ( $($skip,)* fut, .. ) = &mut *futures;
704
705                                // Safety: future is stored on the stack above
706                                // and never moved.
707                                let mut fut = unsafe { $crate::macros::support::Pin::new_unchecked(fut) };
708
709                                // Try polling it
710                                let out = match $crate::macros::support::Future::poll(fut, cx) {
711                                    $crate::macros::support::Poll::Ready(out) => out,
712                                    $crate::macros::support::Poll::Pending => {
713                                        // Track that at least one future is
714                                        // still pending and continue polling.
715                                        is_pending = true;
716                                        continue;
717                                    }
718                                };
719
720                                // Disable the future from future polling.
721                                disabled |= mask;
722
723                                // The future returned a value, check if matches
724                                // the specified pattern.
725                                #[allow(unused_variables)]
726                                #[allow(unused_mut)]
727                                match &out {
728                                    $crate::select_priv_clean_pattern!($bind) => {}
729                                    _ => continue,
730                                }
731
732                                // The select is complete, return the value
733                                return $crate::macros::support::Poll::Ready($crate::select_variant!(__tokio_select_util::Out, ($($skip)*))(out));
734                            }
735                        )*
736                        _ => unreachable!("reaching this means there probably is an off by one bug"),
737                    }
738                }
739
740                if is_pending {
741                    $crate::macros::support::Poll::Pending
742                } else {
743                    // All branches have been disabled.
744                    $crate::macros::support::Poll::Ready(__tokio_select_util::Out::Disabled)
745                }
746            }).await
747        };
748
749        match output {
750            $(
751                $crate::select_variant!(__tokio_select_util::Out, ($($skip)*) ($bind)) => $handle,
752            )*
753            __tokio_select_util::Out::Disabled => $else,
754            _ => unreachable!("failed to match bind"),
755        }
756    }};
757
758    // ==== Normalize =====
759
760    // These rules match a single `select!` branch and normalize it for
761    // processing by the first rule.
762
763    (@ { start=$start:expr; $($t:tt)* } ) => {
764        // No `else` branch
765        $crate::select!(@{ start=$start; $($t)*; panic!("all branches are disabled and there is no else branch") })
766    };
767    (@ { start=$start:expr; $($t:tt)* } else => $else:expr $(,)?) => {
768        $crate::select!(@{ start=$start; $($t)*; $else })
769    };
770    (@ { start=$start:expr; ( $($s:tt)* ) $($t:tt)* } $p:pat = $f:expr, if $c:expr => $h:block, $($r:tt)* ) => {
771        $crate::select!(@{ start=$start; ($($s)* _) $($t)* ($($s)*) $p = $f, if $c => $h, } $($r)*)
772    };
773    (@ { start=$start:expr; ( $($s:tt)* ) $($t:tt)* } $p:pat = $f:expr => $h:block, $($r:tt)* ) => {
774        $crate::select!(@{ start=$start; ($($s)* _) $($t)* ($($s)*) $p = $f, if true => $h, } $($r)*)
775    };
776    (@ { start=$start:expr; ( $($s:tt)* ) $($t:tt)* } $p:pat = $f:expr, if $c:expr => $h:block $($r:tt)* ) => {
777        $crate::select!(@{ start=$start; ($($s)* _) $($t)* ($($s)*) $p = $f, if $c => $h, } $($r)*)
778    };
779    (@ { start=$start:expr; ( $($s:tt)* ) $($t:tt)* } $p:pat = $f:expr => $h:block $($r:tt)* ) => {
780        $crate::select!(@{ start=$start; ($($s)* _) $($t)* ($($s)*) $p = $f, if true => $h, } $($r)*)
781    };
782    (@ { start=$start:expr; ( $($s:tt)* ) $($t:tt)* } $p:pat = $f:expr, if $c:expr => $h:expr ) => {
783        $crate::select!(@{ start=$start; ($($s)* _) $($t)* ($($s)*) $p = $f, if $c => $h, })
784    };
785    (@ { start=$start:expr; ( $($s:tt)* ) $($t:tt)* } $p:pat = $f:expr => $h:expr ) => {
786        $crate::select!(@{ start=$start; ($($s)* _) $($t)* ($($s)*) $p = $f, if true => $h, })
787    };
788    (@ { start=$start:expr; ( $($s:tt)* ) $($t:tt)* } $p:pat = $f:expr, if $c:expr => $h:expr, $($r:tt)* ) => {
789        $crate::select!(@{ start=$start; ($($s)* _) $($t)* ($($s)*) $p = $f, if $c => $h, } $($r)*)
790    };
791    (@ { start=$start:expr; ( $($s:tt)* ) $($t:tt)* } $p:pat = $f:expr => $h:expr, $($r:tt)* ) => {
792        $crate::select!(@{ start=$start; ($($s)* _) $($t)* ($($s)*) $p = $f, if true => $h, } $($r)*)
793    };
794
795    // ===== Entry point =====
796
797    ($(biased;)? else => $else:expr $(,)? ) => {{
798        $else
799    }};
800
801    (biased; $p:pat = $($t:tt)* ) => {
802        $crate::select!(@{ start=0; () } $p = $($t)*)
803    };
804
805    ( $p:pat = $($t:tt)* ) => {
806        // Randomly generate a starting point. This makes `select!` a bit more
807        // fair and avoids always polling the first future.
808        $crate::select!(@{ start={ $crate::macros::support::thread_rng_n(BRANCHES) }; () } $p = $($t)*)
809    };
810
811    () => {
812        compile_error!("select! requires at least one branch.")
813    };
814}}
815
816// And here... we manually list out matches for up to 64 branches... I'm not
817// happy about it either, but this is how we manage to use a declarative macro!
818
819#[macro_export]
820#[doc(hidden)]
821macro_rules! count {
822    () => {
823        0
824    };
825    (_) => {
826        1
827    };
828    (_ _) => {
829        2
830    };
831    (_ _ _) => {
832        3
833    };
834    (_ _ _ _) => {
835        4
836    };
837    (_ _ _ _ _) => {
838        5
839    };
840    (_ _ _ _ _ _) => {
841        6
842    };
843    (_ _ _ _ _ _ _) => {
844        7
845    };
846    (_ _ _ _ _ _ _ _) => {
847        8
848    };
849    (_ _ _ _ _ _ _ _ _) => {
850        9
851    };
852    (_ _ _ _ _ _ _ _ _ _) => {
853        10
854    };
855    (_ _ _ _ _ _ _ _ _ _ _) => {
856        11
857    };
858    (_ _ _ _ _ _ _ _ _ _ _ _) => {
859        12
860    };
861    (_ _ _ _ _ _ _ _ _ _ _ _ _) => {
862        13
863    };
864    (_ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
865        14
866    };
867    (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
868        15
869    };
870    (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
871        16
872    };
873    (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
874        17
875    };
876    (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
877        18
878    };
879    (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
880        19
881    };
882    (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
883        20
884    };
885    (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
886        21
887    };
888    (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
889        22
890    };
891    (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
892        23
893    };
894    (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
895        24
896    };
897    (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
898        25
899    };
900    (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
901        26
902    };
903    (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
904        27
905    };
906    (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
907        28
908    };
909    (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
910        29
911    };
912    (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
913        30
914    };
915    (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
916        31
917    };
918    (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
919        32
920    };
921    (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
922        33
923    };
924    (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
925        34
926    };
927    (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
928        35
929    };
930    (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
931        36
932    };
933    (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
934        37
935    };
936    (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
937        38
938    };
939    (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
940        39
941    };
942    (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
943        40
944    };
945    (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
946        41
947    };
948    (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
949        42
950    };
951    (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
952        43
953    };
954    (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
955        44
956    };
957    (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
958        45
959    };
960    (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
961        46
962    };
963    (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
964        47
965    };
966    (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
967        48
968    };
969    (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
970        49
971    };
972    (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
973        50
974    };
975    (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
976        51
977    };
978    (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
979        52
980    };
981    (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
982        53
983    };
984    (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
985        54
986    };
987    (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
988        55
989    };
990    (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
991        56
992    };
993    (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
994        57
995    };
996    (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
997        58
998    };
999    (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
1000        59
1001    };
1002    (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
1003        60
1004    };
1005    (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
1006        61
1007    };
1008    (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
1009        62
1010    };
1011    (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
1012        63
1013    };
1014    (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
1015        64
1016    };
1017}
1018
1019#[macro_export]
1020#[doc(hidden)]
1021macro_rules! count_field {
1022    ($var:ident. ) => {
1023        $var.0
1024    };
1025    ($var:ident. _) => {
1026        $var.1
1027    };
1028    ($var:ident. _ _) => {
1029        $var.2
1030    };
1031    ($var:ident. _ _ _) => {
1032        $var.3
1033    };
1034    ($var:ident. _ _ _ _) => {
1035        $var.4
1036    };
1037    ($var:ident. _ _ _ _ _) => {
1038        $var.5
1039    };
1040    ($var:ident. _ _ _ _ _ _) => {
1041        $var.6
1042    };
1043    ($var:ident. _ _ _ _ _ _ _) => {
1044        $var.7
1045    };
1046    ($var:ident. _ _ _ _ _ _ _ _) => {
1047        $var.8
1048    };
1049    ($var:ident. _ _ _ _ _ _ _ _ _) => {
1050        $var.9
1051    };
1052    ($var:ident. _ _ _ _ _ _ _ _ _ _) => {
1053        $var.10
1054    };
1055    ($var:ident. _ _ _ _ _ _ _ _ _ _ _) => {
1056        $var.11
1057    };
1058    ($var:ident. _ _ _ _ _ _ _ _ _ _ _ _) => {
1059        $var.12
1060    };
1061    ($var:ident. _ _ _ _ _ _ _ _ _ _ _ _ _) => {
1062        $var.13
1063    };
1064    ($var:ident. _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
1065        $var.14
1066    };
1067    ($var:ident. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
1068        $var.15
1069    };
1070    ($var:ident. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
1071        $var.16
1072    };
1073    ($var:ident. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
1074        $var.17
1075    };
1076    ($var:ident. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
1077        $var.18
1078    };
1079    ($var:ident. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
1080        $var.19
1081    };
1082    ($var:ident. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
1083        $var.20
1084    };
1085    ($var:ident. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
1086        $var.21
1087    };
1088    ($var:ident. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
1089        $var.22
1090    };
1091    ($var:ident. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
1092        $var.23
1093    };
1094    ($var:ident. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
1095        $var.24
1096    };
1097    ($var:ident. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
1098        $var.25
1099    };
1100    ($var:ident. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
1101        $var.26
1102    };
1103    ($var:ident. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
1104        $var.27
1105    };
1106    ($var:ident. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
1107        $var.28
1108    };
1109    ($var:ident. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
1110        $var.29
1111    };
1112    ($var:ident. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
1113        $var.30
1114    };
1115    ($var:ident. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
1116        $var.31
1117    };
1118    ($var:ident. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
1119        $var.32
1120    };
1121    ($var:ident. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
1122        $var.33
1123    };
1124    ($var:ident. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
1125        $var.34
1126    };
1127    ($var:ident. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
1128        $var.35
1129    };
1130    ($var:ident. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
1131        $var.36
1132    };
1133    ($var:ident. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
1134        $var.37
1135    };
1136    ($var:ident. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
1137        $var.38
1138    };
1139    ($var:ident. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
1140        $var.39
1141    };
1142    ($var:ident. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
1143        $var.40
1144    };
1145    ($var:ident. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
1146        $var.41
1147    };
1148    ($var:ident. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
1149        $var.42
1150    };
1151    ($var:ident. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
1152        $var.43
1153    };
1154    ($var:ident. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
1155        $var.44
1156    };
1157    ($var:ident. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
1158        $var.45
1159    };
1160    ($var:ident. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
1161        $var.46
1162    };
1163    ($var:ident. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
1164        $var.47
1165    };
1166    ($var:ident. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
1167        $var.48
1168    };
1169    ($var:ident. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
1170        $var.49
1171    };
1172    ($var:ident. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
1173        $var.50
1174    };
1175    ($var:ident. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
1176        $var.51
1177    };
1178    ($var:ident. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
1179        $var.52
1180    };
1181    ($var:ident. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
1182        $var.53
1183    };
1184    ($var:ident. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
1185        $var.54
1186    };
1187    ($var:ident. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
1188        $var.55
1189    };
1190    ($var:ident. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
1191        $var.56
1192    };
1193    ($var:ident. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
1194        $var.57
1195    };
1196    ($var:ident. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
1197        $var.58
1198    };
1199    ($var:ident. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
1200        $var.59
1201    };
1202    ($var:ident. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
1203        $var.60
1204    };
1205    ($var:ident. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
1206        $var.61
1207    };
1208    ($var:ident. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
1209        $var.62
1210    };
1211    ($var:ident. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
1212        $var.63
1213    };
1214    ($var:ident. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) => {
1215        $var.64
1216    };
1217}
1218
1219#[macro_export]
1220#[doc(hidden)]
1221macro_rules! select_variant {
1222    ($($p:ident)::*, () $($t:tt)*) => {
1223        $($p)::*::_0 $($t)*
1224    };
1225    ($($p:ident)::*, (_) $($t:tt)*) => {
1226        $($p)::*::_1 $($t)*
1227    };
1228    ($($p:ident)::*, (_ _) $($t:tt)*) => {
1229        $($p)::*::_2 $($t)*
1230    };
1231    ($($p:ident)::*, (_ _ _) $($t:tt)*) => {
1232        $($p)::*::_3 $($t)*
1233    };
1234    ($($p:ident)::*, (_ _ _ _) $($t:tt)*) => {
1235        $($p)::*::_4 $($t)*
1236    };
1237    ($($p:ident)::*, (_ _ _ _ _) $($t:tt)*) => {
1238        $($p)::*::_5 $($t)*
1239    };
1240    ($($p:ident)::*, (_ _ _ _ _ _) $($t:tt)*) => {
1241        $($p)::*::_6 $($t)*
1242    };
1243    ($($p:ident)::*, (_ _ _ _ _ _ _) $($t:tt)*) => {
1244        $($p)::*::_7 $($t)*
1245    };
1246    ($($p:ident)::*, (_ _ _ _ _ _ _ _) $($t:tt)*) => {
1247        $($p)::*::_8 $($t)*
1248    };
1249    ($($p:ident)::*, (_ _ _ _ _ _ _ _ _) $($t:tt)*) => {
1250        $($p)::*::_9 $($t)*
1251    };
1252    ($($p:ident)::*, (_ _ _ _ _ _ _ _ _ _) $($t:tt)*) => {
1253        $($p)::*::_10 $($t)*
1254    };
1255    ($($p:ident)::*, (_ _ _ _ _ _ _ _ _ _ _) $($t:tt)*) => {
1256        $($p)::*::_11 $($t)*
1257    };
1258    ($($p:ident)::*, (_ _ _ _ _ _ _ _ _ _ _ _) $($t:tt)*) => {
1259        $($p)::*::_12 $($t)*
1260    };
1261    ($($p:ident)::*, (_ _ _ _ _ _ _ _ _ _ _ _ _) $($t:tt)*) => {
1262        $($p)::*::_13 $($t)*
1263    };
1264    ($($p:ident)::*, (_ _ _ _ _ _ _ _ _ _ _ _ _ _) $($t:tt)*) => {
1265        $($p)::*::_14 $($t)*
1266    };
1267    ($($p:ident)::*, (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _) $($t:tt)*) => {
1268        $($p)::*::_15 $($t)*
1269    };
1270    ($($p:ident)::*, (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) $($t:tt)*) => {
1271        $($p)::*::_16 $($t)*
1272    };
1273    ($($p:ident)::*, (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) $($t:tt)*) => {
1274        $($p)::*::_17 $($t)*
1275    };
1276    ($($p:ident)::*, (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) $($t:tt)*) => {
1277        $($p)::*::_18 $($t)*
1278    };
1279    ($($p:ident)::*, (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) $($t:tt)*) => {
1280        $($p)::*::_19 $($t)*
1281    };
1282    ($($p:ident)::*, (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) $($t:tt)*) => {
1283        $($p)::*::_20 $($t)*
1284    };
1285    ($($p:ident)::*, (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) $($t:tt)*) => {
1286        $($p)::*::_21 $($t)*
1287    };
1288    ($($p:ident)::*, (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) $($t:tt)*) => {
1289        $($p)::*::_22 $($t)*
1290    };
1291    ($($p:ident)::*, (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) $($t:tt)*) => {
1292        $($p)::*::_23 $($t)*
1293    };
1294    ($($p:ident)::*, (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) $($t:tt)*) => {
1295        $($p)::*::_24 $($t)*
1296    };
1297    ($($p:ident)::*, (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) $($t:tt)*) => {
1298        $($p)::*::_25 $($t)*
1299    };
1300    ($($p:ident)::*, (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) $($t:tt)*) => {
1301        $($p)::*::_26 $($t)*
1302    };
1303    ($($p:ident)::*, (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) $($t:tt)*) => {
1304        $($p)::*::_27 $($t)*
1305    };
1306    ($($p:ident)::*, (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) $($t:tt)*) => {
1307        $($p)::*::_28 $($t)*
1308    };
1309    ($($p:ident)::*, (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) $($t:tt)*) => {
1310        $($p)::*::_29 $($t)*
1311    };
1312    ($($p:ident)::*, (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) $($t:tt)*) => {
1313        $($p)::*::_30 $($t)*
1314    };
1315    ($($p:ident)::*, (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) $($t:tt)*) => {
1316        $($p)::*::_31 $($t)*
1317    };
1318    ($($p:ident)::*, (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) $($t:tt)*) => {
1319        $($p)::*::_32 $($t)*
1320    };
1321    ($($p:ident)::*, (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) $($t:tt)*) => {
1322        $($p)::*::_33 $($t)*
1323    };
1324    ($($p:ident)::*, (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) $($t:tt)*) => {
1325        $($p)::*::_34 $($t)*
1326    };
1327    ($($p:ident)::*, (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) $($t:tt)*) => {
1328        $($p)::*::_35 $($t)*
1329    };
1330    ($($p:ident)::*, (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) $($t:tt)*) => {
1331        $($p)::*::_36 $($t)*
1332    };
1333    ($($p:ident)::*, (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) $($t:tt)*) => {
1334        $($p)::*::_37 $($t)*
1335    };
1336    ($($p:ident)::*, (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) $($t:tt)*) => {
1337        $($p)::*::_38 $($t)*
1338    };
1339    ($($p:ident)::*, (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) $($t:tt)*) => {
1340        $($p)::*::_39 $($t)*
1341    };
1342    ($($p:ident)::*, (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) $($t:tt)*) => {
1343        $($p)::*::_40 $($t)*
1344    };
1345    ($($p:ident)::*, (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) $($t:tt)*) => {
1346        $($p)::*::_41 $($t)*
1347    };
1348    ($($p:ident)::*, (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) $($t:tt)*) => {
1349        $($p)::*::_42 $($t)*
1350    };
1351    ($($p:ident)::*, (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) $($t:tt)*) => {
1352        $($p)::*::_43 $($t)*
1353    };
1354    ($($p:ident)::*, (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) $($t:tt)*) => {
1355        $($p)::*::_44 $($t)*
1356    };
1357    ($($p:ident)::*, (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) $($t:tt)*) => {
1358        $($p)::*::_45 $($t)*
1359    };
1360    ($($p:ident)::*, (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) $($t:tt)*) => {
1361        $($p)::*::_46 $($t)*
1362    };
1363    ($($p:ident)::*, (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) $($t:tt)*) => {
1364        $($p)::*::_47 $($t)*
1365    };
1366    ($($p:ident)::*, (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) $($t:tt)*) => {
1367        $($p)::*::_48 $($t)*
1368    };
1369    ($($p:ident)::*, (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) $($t:tt)*) => {
1370        $($p)::*::_49 $($t)*
1371    };
1372    ($($p:ident)::*, (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) $($t:tt)*) => {
1373        $($p)::*::_50 $($t)*
1374    };
1375    ($($p:ident)::*, (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) $($t:tt)*) => {
1376        $($p)::*::_51 $($t)*
1377    };
1378    ($($p:ident)::*, (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) $($t:tt)*) => {
1379        $($p)::*::_52 $($t)*
1380    };
1381    ($($p:ident)::*, (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) $($t:tt)*) => {
1382        $($p)::*::_53 $($t)*
1383    };
1384    ($($p:ident)::*, (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) $($t:tt)*) => {
1385        $($p)::*::_54 $($t)*
1386    };
1387    ($($p:ident)::*, (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) $($t:tt)*) => {
1388        $($p)::*::_55 $($t)*
1389    };
1390    ($($p:ident)::*, (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) $($t:tt)*) => {
1391        $($p)::*::_56 $($t)*
1392    };
1393    ($($p:ident)::*, (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) $($t:tt)*) => {
1394        $($p)::*::_57 $($t)*
1395    };
1396    ($($p:ident)::*, (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) $($t:tt)*) => {
1397        $($p)::*::_58 $($t)*
1398    };
1399    ($($p:ident)::*, (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) $($t:tt)*) => {
1400        $($p)::*::_59 $($t)*
1401    };
1402    ($($p:ident)::*, (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) $($t:tt)*) => {
1403        $($p)::*::_60 $($t)*
1404    };
1405    ($($p:ident)::*, (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) $($t:tt)*) => {
1406        $($p)::*::_61 $($t)*
1407    };
1408    ($($p:ident)::*, (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) $($t:tt)*) => {
1409        $($p)::*::_62 $($t)*
1410    };
1411    ($($p:ident)::*, (_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) $($t:tt)*) => {
1412        $($p)::*::_63 $($t)*
1413    };
1414}