From 01ca3abeb9917271156242268680c95e0a389762 Mon Sep 17 00:00:00 2001 From: nyyu Date: Sun, 14 Mar 2021 12:30:04 +0100 Subject: [PATCH] Fix role aggregate --- src/cgg_data_source.rs | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/cgg_data_source.rs b/src/cgg_data_source.rs index 7dd4bd1..718d2c5 100644 --- a/src/cgg_data_source.rs +++ b/src/cgg_data_source.rs @@ -132,17 +132,14 @@ impl DataSource for CGGDataSource { let mut champions: IndexMap> = IndexMap::new(); for champ in &datas.lol.champions_report { let id = champ.champion_id.to_string(); - let mut roles: Vec = Vec::new(); - + if champions.contains_key(&id) { - let c = champions.get(&id).unwrap(); - let mut new_roles = c.clone(); - new_roles.push(champ.role.clone()); - } else { + let mut roles = champions.get(&id).unwrap().clone(); roles.push(champ.role.clone()); - } - - champions.insert(id, roles); + champions.insert(id, roles); + } else { + champions.insert(id, [champ.role.clone()].to_vec()); + } } for report in datas.lol.champions_report {