From 37a4e61ce5b73c4573bc0eba41b6b12274b50300 Mon Sep 17 00:00:00 2001 From: Mylloon Date: Tue, 16 Aug 2022 09:33:35 +0200 Subject: [PATCH] use tuple instead of hashmaps --- src/io.rs | 9 ++++++++- src/timetable.rs | 6 ++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/io.rs b/src/io.rs index 45ba827..17fa11d 100644 --- a/src/io.rs +++ b/src/io.rs @@ -3,7 +3,12 @@ use ics::{ Event, ICalendar, }; -type T = Vec; +type T = ( + // Schedules + Vec, + // Timetable per days with the semester as the key + (usize, Vec), +); type D = std::collections::HashMap< usize, Vec<(chrono::DateTime, chrono::DateTime)>, @@ -36,5 +41,7 @@ pub fn export(_timetable: T, _dates: D) -> ICalendar<'static> { calendar.save_file("target/debug2.ics").unwrap(); + println!("{:#?} - {:#?}", _timetable, _dates); + calendar } diff --git a/src/timetable.rs b/src/timetable.rs index ea81a47..83917eb 100644 --- a/src/timetable.rs +++ b/src/timetable.rs @@ -1,5 +1,3 @@ -use std::collections::HashMap; - use scraper::{Html, Selector}; pub mod models; @@ -9,7 +7,7 @@ pub async fn timetable( year: i8, semester: i8, letter: Option, -) -> HashMap> { +) -> (Vec, (usize, Vec)) { let document = get_webpage(year, semester, letter) .await .expect("Can't reach timetable website."); @@ -100,7 +98,7 @@ pub async fn timetable( panic!("Error when building the timetable."); } - HashMap::from([(semester as usize, timetable)]) + (schedules, (semester as usize, timetable)) } /// Get timetable webpage