79587616

Date: 2025-04-22 23:56:13
Score: 0.5
Natty:
Report link

Solution

I didn't consider that we could simply pass the pointers around to construct what I wanted without needing to consume the iterator multiple times.

Create three vectors to store the references.

let mut As = Vec::new();
let mut Bs = Vec::new();
let mut Cs = Vec::new();
states.iter_mut().for_each(|(state)| match state {
   State::A(a) => As.push(a),
   State::B(b) => Bs.push(b),
   State::C(c) => Cs.push(c),
})
Reasons:
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (0.5):
Posted by: rhalameddine