diff --git a/src/main.rs b/src/main.rs index 28f8ebe..1bd4d9d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -139,7 +139,8 @@ async fn get_scores(Query(params): Query) -> impl IntoResponse { SortedBy::Time => { for i in 0..count as usize { if score.time > scores[i].time { - *scores.get_mut(i).expect("failed to get score (impossible)") = response; + scores.insert(i, response); + scores.remove(count as usize); break; } } @@ -147,7 +148,8 @@ async fn get_scores(Query(params): Query) -> impl IntoResponse { SortedBy::Score => { for i in 0..count as usize { if score.score > scores[i].score { - *scores.get_mut(i).expect("failed to get score (impossible)") = response; + scores.insert(i, response); + scores.remove(count as usize); break; } }