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

This commit is contained in:
nyyu 2021-03-14 11:01:37 +01:00
parent 8c754cfadc
commit 66a9ded315

View File

@ -64,9 +64,8 @@ struct Info {
id: String
}
static mut CHAMPIONS_REPORT: Vec<ChampionReport> = Vec::new();
lazy_static! {
static ref CHAMPIONS_REPORT: Mutex<Vec<ChampionReport>> = Mutex::new(Vec::new());
static ref CHAMPIONS_STATS: Mutex<HashMap<String, ChampStat>> = Mutex::new(HashMap::new());
}
@ -150,8 +149,8 @@ impl DataSource for CGGDataSource {
champions.insert(id, roles);
}
unsafe {
CHAMPIONS_REPORT = datas.lol.champions_report;
for report in datas.lol.champions_report {
CHAMPIONS_REPORT.lock().unwrap().push(report);
}
(champions, patch)
@ -165,11 +164,10 @@ impl DataSource for CGGDataSource {
) -> Option<(Vec<Value>, f64)> {
let mut some_champ: Option<&ChampionReport> = None;
unsafe {
for champion in &CHAMPIONS_REPORT {
if champion.champion_id.to_string() == champ.key && champion.role == position {
some_champ = Some(champion);
}
let reports = CHAMPIONS_REPORT.lock().unwrap();
for champion in reports.iter() {
if champion.champion_id.to_string() == champ.key && champion.role == position {
some_champ = Some(champion);
}
}
if let Some(champ) = some_champ {