Hi! I'm trying to move a bulk of computation into compile time and I have the following pattern:
const fn expensive_computation<T, U, V>() -> (T, U, V);
So, few values (three tables of different types and sizes) are being computed at the same time and depend on each other. And then I want to declare the constants:
const (A, B, C): (T, U, V) = expensive_computation();
The problem is that this syntax is not valid in Rust. The workaround I have is
const A: T = expensive_computation().0;
const B: U = expensive_computation().1;
const C: V = expensive_computation().2;
But this is both not elegant and slows down the compilation by a significant margin because now I have to compute the same set of values three times instead of just one. It would be awesome if the tuple destructuring syntax was available for constants: the compile-time evaluation and syntax would get much cleaner.
I think the way to do this would not make tuples special, but allow all destructuring patterns. That is, const and static are currently defined to take only identifiers:
Good point, thanks! That would kind of solve my problem but the larger problem would still be there, so I think it'll be valuable to allow destructuring patterns in consts in general.