Remove clone
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
nyyu 2021-03-14 14:57:31 +01:00
parent 2b3ed7fcfa
commit f36fa0c964
2 changed files with 8 additions and 8 deletions

View file

@ -125,19 +125,19 @@ impl DataSource for CGGDataSource {
CHAMPIONS_STATS CHAMPIONS_STATS
.lock() .lock()
.unwrap() .unwrap()
.insert(entry.0.clone(), entry.1.clone()); .insert(entry.0.to_owned(), entry.1.to_owned());
} }
let patch = datas.lol.champions_report[0].patch.clone(); let patch = datas.lol.champions_report[0].patch.to_owned();
let mut champions: IndexMap<String, Vec<String>> = IndexMap::new(); let mut champions: IndexMap<String, Vec<String>> = IndexMap::new();
for champ in &datas.lol.champions_report { for champ in &datas.lol.champions_report {
let id = champ.champion_id.to_string(); let id = champ.champion_id.to_string();
if champions.contains_key(&id) { if champions.contains_key(&id) {
let mut roles = champions.get(&id).unwrap().clone(); let mut roles = champions.get(&id).unwrap().to_owned();
roles.push(champ.role.clone()); roles.push(champ.role.to_owned());
champions.insert(id, roles); champions.insert(id, roles);
} else { } else {
champions.insert(id, vec![champ.role.clone()]); champions.insert(id, vec![champ.role.to_owned()]);
} }
} }
@ -193,7 +193,7 @@ impl DataSource for CGGDataSource {
let champs_stats = CHAMPIONS_STATS.lock().unwrap(); let champs_stats = CHAMPIONS_STATS.lock().unwrap();
for val in champs_stats.values() { for val in champs_stats.values() {
if val.champion_id.is_some() && val.champion_id.unwrap() == champ.champion_id { if val.champion_id.is_some() && val.champion_id.unwrap() == champ.champion_id {
key = val.stats.as_ref().unwrap().id.clone(); key = val.stats.as_ref().unwrap().id.to_owned();
} }
} }

View file

@ -102,7 +102,7 @@ fn main() {
); );
for (id, positions) in &champs { for (id, positions) in &champs {
let mut champ_id: String = String::from(id); let mut champ_id: String = id.to_owned();
if !champion.data.contains_key(&champ_id) { if !champion.data.contains_key(&champ_id) {
champ_id = get_champ_from_key(&champion, &champ_id); champ_id = get_champ_from_key(&champion, &champ_id);
@ -134,7 +134,7 @@ fn main() {
fn get_champ_from_key(champs: &Champion, key: &str) -> String { fn get_champ_from_key(champs: &Champion, key: &str) -> String {
for champ in champs.data.values() { for champ in champs.data.values() {
if key == champ.key { if key == champ.key {
return champ.id.clone(); return champ.id.to_owned();
} }
} }
String::new() String::new()