minus-squareGobbel2000@feddit.detoRust@programming.dev•Question on holding related data in a struct.linkfedilinkarrow-up0·8 months agoI don’t think there is a good way of having references within the same struct, but you could store reference counted matches: matches: Vec<Rc<Match>>, players: HashMap<String, Rc<Match>>, You would still have to make sure that the players map is updated, maybe weak references are useful there. Maybe you could also consider storing the players of a match in the match itself, not outside. linkfedilink
Gobbel2000@feddit.de to Ukrainekrieg@feddit.de · 9 months agoDie Lage im Osten - Eindrücke von ukrainischen Frontsoldatenplus-squarereportagen.comexternal-linkmessage-square0fedilinkarrow-up11arrow-down10
arrow-up11arrow-down1external-linkDie Lage im Osten - Eindrücke von ukrainischen Frontsoldatenplus-squarereportagen.comGobbel2000@feddit.de to Ukrainekrieg@feddit.de · 9 months agomessage-square0fedilink
I don’t think there is a good way of having references within the same struct, but you could store reference counted matches:
matches: Vec<Rc<Match>>, players: HashMap<String, Rc<Match>>,
You would still have to make sure that the
players
map is updated, maybe weak references are useful there.Maybe you could also consider storing the players of a match in the match itself, not outside.