More parsing
This commit is contained in:
@@ -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::{
|
||||
|
||||
@@ -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<_>>());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user