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