このマクロを書く方法はありますか?大規模な配列をあまり冗長な方法で書くことができないように配列のアクセスを拡張しますか?Rustのマクロでインデックスを繰り返し展開するのを避けるにはどうすればいいですか?
/// Avoid manually expanding an expression, eg:
///
/// let array = unpack!([some.vec; 3]);
///
/// Expands into: [some.vec[0], some.vec[1], some.vec[2]]
///
/// Supports expanding into different bracket types based on the input args.
macro_rules! unpack {
([$v_:expr; 2]) => { { let v = $v_; [v[0], v[1]] } };
(($v_:expr; 2)) => { { let v = $v_; (v[0], v[1]) } };
({$v_:expr; 2}) => { { let v = $v_; {v[0], v[1]} } };
([$v_:expr; 3]) => { { let v = $v_; [v[0], v[1], v[2]] } };
(($v_:expr; 3)) => { { let v = $v_; (v[0], v[1], v[2]) } };
({$v_:expr; 3}) => { { let v = $v_; {v[0], v[1], v[2]} } };
([$v_:expr; 4]) => { { let v = $v_; [v[0], v[1], v[2], v[3]] } };
(($v_:expr; 4)) => { { let v = $v_; (v[0], v[1], v[2], v[3]) } };
({$v_:expr; 4}) => { { let v = $v_; {v[0], v[1], v[2], v[3]} } };
}
[The Little Book of Rust Macros](https://danielkeep.github.io/tlborm/book/README.html)を読んでいますか? – Shepmaster