Hi, I frequently want to unpack a tuple into a "list" of values, for example when calling a function or when constructing an enum variant:
let tuple = ("abc", 3, (1, 2));
fn myfn(s: &str, a: usize, bc: (usize, usize)) { ... }
enum MyEnum<'a> {
Args(&'a str, usize, (usize, usize)),
NoArgs,
}
myfn(tuple.clone().unpack());
let args = MyEnum::Args(tuple.unpack());
Maybe with a better syntax of some kind, maybe tuple..
or *tuple
.
The current syntax would be (ignoring cloning):
let (s, a, bc) = tuple;
myfn(s, a, bc);
let args = MyEnum::Args(s, a, bc);
What do you think about this, may this eventually be added to the language?