I essentially have a situation like this:
let x = vec![
500,
600,
700,
1,
2,
3,
];
let y = vec![
4,
5,
500,
600,
700,
6,
7,
];
And I want to pull the 500, 600, 700, out of the two vecs.
I tried using a macro:
macro_rules! common {
() => {
500,
600,
700,
}
let x = vec![
common!(),
1,
2,
3,
];
let y = vec![
4,
5,
common!(),
6,
7,
];
which doesn't work.
And I tried destructuring an array:
const fn common() -> [usize; 3] {
[500, 600, 700]
}
let x = vec![
..common(),
1,
2,
3,
];
let y = vec![
4,
5,
..common(),
6,
7,
];
Which also doesn't work.
What's the right way to do this?