More parsing

This commit is contained in:
Lukas Wölfer
2025-10-04 11:11:13 +02:00
parent 965d1560f7
commit a5ef3f6569
2 changed files with 20 additions and 3 deletions

View File

@@ -12,7 +12,7 @@
clippy::cast_possible_wrap,
reason = "Disable this for most of the time, enable this for cleanup later"
)]
#![feature(hash_map_macro)]
#![feature(never_type)]
use mwbot::{

View File

@@ -3,7 +3,7 @@ use scraper::{ElementRef, Html, Selector};
use crate::{
app_signature,
dance_info::DanceInfo,
dance_info::{DanceInfo, DanceRank},
worldsdc::{DanceInfoError, DanceInfoParser},
};
@@ -49,7 +49,24 @@ fn parse_details(d: &[Vec<String>]) {
}
fn parse_stats(d: &[Vec<String>]) {
let chapters = d.chunk_by(|_, b| b.len() != 1);
let chapters = d.chunk_by(|_, b| b.len() != 1).map(|v| {
let (a, b) = v.split_first().unwrap();
let a = a.first().unwrap();
let b = b
.iter()
.map(|v| [v.first().unwrap(), v.last().unwrap()])
.collect::<Vec<_>>();
(a, b)
});
hash_map! {
"Champions" => DanceRank::Champions,
"All-Stars" => DanceRank::AllStars,
"Advanced" => DanceRank::Advanced,
"Intermediate" => DanceRank::Intermediate,
"Newcomer" => DanceRank::Newcomer,
"Novice" => DanceRank::Novice,
};
dbg!(chapters.collect::<Vec<_>>());
}