diff --git a/src/game.rs b/src/game.rs index 938588e..bc69584 100644 --- a/src/game.rs +++ b/src/game.rs @@ -107,16 +107,13 @@ impl> OwnedGame { convergence: crate::ConvergenceOptions, ) -> Self { let mut arena = ScratchArena::new(); - let g = Game::ranked_with_arena( - teams.clone(), - &result, - &weights, - p_draw, - convergence, - &mut arena, - ); + + // `Game` takes the teams by value and is dropped here, so take the vec + // back out of it rather than handing it a clone. + let g = Game::ranked_with_arena(teams, &result, &weights, p_draw, convergence, &mut arena); + Self { - teams, + teams: g.teams, likelihoods: g.likelihoods, log_evidence: g.log_evidence, } @@ -130,16 +127,18 @@ impl> OwnedGame { convergence: crate::ConvergenceOptions, ) -> Self { let mut arena = ScratchArena::new(); + let g = Game::scored_with_arena( - teams.clone(), + teams, &scores, &weights, score_sigma, convergence, &mut arena, ); + Self { - teams, + teams: g.teams, likelihoods: g.likelihoods, log_evidence: g.log_evidence, } diff --git a/src/history.rs b/src/history.rs index 746ca84..912414f 100644 --- a/src/history.rs +++ b/src/history.rs @@ -650,10 +650,10 @@ impl, O: Observer, K: Eq + Hash + Clone> History, O: Observer, K: Eq + Hash + Clone> History { pub(crate) fn add_events_with_prior( &mut self, - composition: Vec>>, - results: Option>>, + mut composition: Vec>>, + mut results: Option>>, times: Vec, - weights: Option>>>, + mut weights: Option>>>, kinds: Vec, mut priors: HashMap>, ) -> Result<(), InferenceError> { @@ -743,6 +743,20 @@ impl, O: Observer, K: Eq + Hash + Clone> History, O: Observer, K: Eq + Hash + Clone> History>(); - let results = results - .as_ref() - .map(|results| (i..j).map(|e| results[o[e]].clone()).collect::>()); + let results = results.as_mut().map(|results| { + (i..j) + .map(|e| std::mem::take(&mut results[o[e]])) + .collect::>() + }); - let weights = weights - .as_ref() - .map(|weights| (i..j).map(|e| weights[o[e]].clone()).collect::>()); + let weights = weights.as_mut().map(|weights| { + (i..j) + .map(|e| std::mem::take(&mut weights[o[e]])) + .collect::>() + }); let kinds_chunk: Vec = (i..j).map(|e| kinds[o[e]]).collect();