|
| 1 | +# Survey questions |
| 2 | + |
| 3 | +This survey is meant to both measure interest in variadic generics and gather data about how they might be used once implemented. |
| 4 | + |
| 5 | +You can think of variadic generics as “being able to implement a trait for tuples with an arbitrary number of fields”. |
| 6 | + |
| 7 | +Variadics in Rust might look like this (placeholder syntax): |
| 8 | + |
| 9 | +```rust |
| 10 | +impl<...Ts: SomeTrait> SomeTrait for (...Ts) { |
| 11 | + fn do_stuff(&self) -> u32 { |
| 12 | + let mut sum = 0; |
| 13 | + for member in ...self { |
| 14 | + // The trait bounds ensure each member has a do_stuff() method |
| 15 | + sum += member.do_stuff(); |
| 16 | + } |
| 17 | + sum |
| 18 | + } |
| 19 | +} |
| 20 | + |
| 21 | +let value: u32 = (0, 0.5, "hello", Some("hello"), false).do_stuff(); |
| 22 | +``` |
| 23 | + |
| 24 | +See [Analysing variadics, and how to add them to Rust](https://poignardazur.github.io/2021/01/30/variadic-generics/) for a full overview of features associated with variadic generics, and possible use-cases. |
| 25 | + |
| 26 | +This survey is fully anonymous and should take you approximately 5 minutes to complete. |
| 27 | + |
| 28 | + |
| 29 | +### How long have you been using Rust? |
| 30 | + |
| 31 | +Type: select one (optional) |
| 32 | + |
| 33 | +- Never |
| 34 | +- Zero to two years |
| 35 | +- Two to four years |
| 36 | +- Four to six years |
| 37 | +- More than six years |
| 38 | + |
| 39 | + |
| 40 | +### Have you heard about variadic generics before? |
| 41 | + |
| 42 | +Type: select all that apply |
| 43 | + |
| 44 | +- Yes, through Pre-RFCs and discussions on [`internals.rust-lang.org`](https://internals.rust-lang.org). |
| 45 | +- Yes, through discussions on Reddit. |
| 46 | +- Yes, through blog posts on [`poignardazur.github.io`](https://poignardazur.github.io/2025/07/09/variadic-generics-dead-ends/). |
| 47 | +- Yes, through other programming languages. |
| 48 | +- Yes, through other means: (open response) |
| 49 | +- No. |
| 50 | + |
| 51 | + |
| 52 | +### Are there cases where variadic generics would have made your project easier? |
| 53 | + |
| 54 | +If you knew about variadics, are there cases where you've wanted them to be implemented in Rust? |
| 55 | +If you haven't heard about variadics before, are there cases where you've wanted to be able to iterate over lists of different types? |
| 56 | + |
| 57 | +Type: select one |
| 58 | + |
| 59 | +- Yes |
| 60 | +- No [`NEXT`](#variadic-type-mappings) |
| 61 | + |
| 62 | +### Can you give more details about the use-case? |
| 63 | + |
| 64 | +Please write a description of the project and what you would have needed variadics for. |
| 65 | +Be as detailed as you like, more detail is better. |
| 66 | + |
| 67 | +Type: free text |
| 68 | + |
| 69 | + |
| 70 | +## Variadic type mappings |
| 71 | + |
| 72 | +The following section refers to "mappings" of variadic generics. |
| 73 | + |
| 74 | +In this context, variadic mappings refer to code that takes N-tuples of types as generic parameters, and refers to N-tuples of types derived from those parameters, where each type in the tuple is transformed in the same way. |
| 75 | + |
| 76 | +For example: |
| 77 | + |
| 78 | +```rust |
| 79 | +impl<...Ts> UnwrapAll for (Option<...Ts>) { |
| 80 | + type Unwrapped = (...Ts); |
| 81 | + fn unwrap_all(self) -> Self::Unwrapped { |
| 82 | + for option in ...self { |
| 83 | + option.unwrap() |
| 84 | + } |
| 85 | + } |
| 86 | +} |
| 87 | + |
| 88 | +let my_gift_boxes = (Some(1), Some(true), Some("hello")); |
| 89 | +let opened_gifts = my_gift_boxes.unwrap_all(); |
| 90 | +assert_eq!(opened_gifts, (1, true, "hello")); |
| 91 | +``` |
| 92 | + |
| 93 | +In the above example, the trait `UnwrapAll` maps `(Option<u32>, Option<bool>, Option<&str>)` to `(u32, bool, &str)`. |
| 94 | + |
| 95 | +### Are there cases where variadic mappings would have made your project easier? |
| 96 | + |
| 97 | +Type: select one |
| 98 | + |
| 99 | +- Yes (same project as above) |
| 100 | +- Yes (another project) |
| 101 | +- No [`NEXT`](#non-linear-variadic-generics) |
| 102 | + |
| 103 | +### Can you give more details about the project? |
| 104 | + |
| 105 | +Be as detailed as you like, more detail is better. |
| 106 | + |
| 107 | +If it is the same project as before, you can include more details about how you would have used variadic mappings specifically. |
| 108 | + |
| 109 | +If you do not have anything to add, leave the answer empty. |
| 110 | + |
| 111 | +Type: free text (optional) |
| 112 | + |
| 113 | + |
| 114 | +## Non-linear variadic generics |
| 115 | + |
| 116 | +The following section refers to "non-linear" variadic generics. |
| 117 | + |
| 118 | +"Linear" variadics generics, in this context, means generics that only map over types in a fixed order, and otherwise preserve a one-to-one correspondence between type parameters and derived types. |
| 119 | + |
| 120 | +All the examples so far have been linear variadics. |
| 121 | + |
| 122 | +"Non-linear" variadics generics mean things like filtering a tuple of types to only keep those that implement a trait, or reversing a tuple of types, or finding the first type in a tuple that implements a trait. |
| 123 | + |
| 124 | +```rust |
| 125 | +fn get_children<...Ts>(parents: (...Ts)) -> (for <T of ...Ts where T: Parent> T::Child) { |
| 126 | + for parent in ...parents where parent: Parent { |
| 127 | + parent.child() |
| 128 | + } |
| 129 | +} |
| 130 | +``` |
| 131 | + |
| 132 | +### Are there cases where non-linear variadic generics would have made your project easier? |
| 133 | + |
| 134 | +Type: select one |
| 135 | + |
| 136 | +- Yes (same project as above) |
| 137 | +- Yes (another project) |
| 138 | +- No [`NEXT`](#how-high-a-priority-would-you-say-variadics-are-for-you) |
| 139 | + |
| 140 | +### Can you give more details about the project? |
| 141 | + |
| 142 | +Be as detailed as you like, more detail is better. |
| 143 | + |
| 144 | +If it's the same project as before, you can include more details about how you would have used non-linear variadics specifically. |
| 145 | + |
| 146 | +If you do not have anything to add, leave the answer empty. |
| 147 | + |
| 148 | +Type: free text (optional) |
| 149 | + |
| 150 | + |
| 151 | +## How high a priority would you say variadics are for you? |
| 152 | + |
| 153 | +Type: select one |
| 154 | + |
| 155 | +- It should be the highest priority feature. |
| 156 | +- Very important. |
| 157 | +- Moderately important. |
| 158 | +- Nice to have. |
| 159 | +- I don't care. |
| 160 | +- I don't want Rust to have variadics. |
0 commit comments