I have a routine that plays with objects in a container and references to those objects stored in another 2 containers.
However, I am not finding the rust way of doing this, the lifetime inference seems to forbid this and I don't know how to resolve it
fn main() {
let mut deck : Deck = Deck::new();
let mut p1 : Hand = Hand::new();
let mut p2 : Hand = Hand::new();
do_hands(|data: &[Card]| -> Result<(),()> {
for card in data {
deck.insert(card.id, CardCell::new(*card));
let card: &CardCell = deck.get_mut(&card.id).unwrap();
handle_hand(&mut card, &mut p1, &mut p2);
}
return Ok(());
});
}
Here is the full playground link: https://play.rust-lang.org/?gist=6079ade83e3fcf06f35397eac2e82d05&version=nightly