don't crash when the selected courses don't have multiples TP/TD options

This commit is contained in:
Mylloon 2024-01-01 11:24:27 +01:00
parent 220f46c5de
commit 77c2444de1
Signed by: Anri
GPG key ID: A82D63DFF8D1317F

View file

@ -104,13 +104,16 @@ fn tdtp(timetable: &mut Timetable) {
let mut multiselected: Vec<String> = td_or_tp.iter().map(get_selection).collect(); let mut multiselected: Vec<String> = td_or_tp.iter().map(get_selection).collect();
multiselected.sort(); multiselected.sort();
let defaults = vec![false; multiselected.len()]; let mut selections = vec![];
let selections = MultiSelect::new() if !multiselected.is_empty() {
.with_prompt(format!("Choisis tes horaires de TD/TP {}", DISCLAIMER)) let defaults = vec![false; multiselected.len()];
.items(&multiselected[..]) selections = MultiSelect::new()
.defaults(&defaults[..]) .with_prompt(format!("Choisis tes horaires de TD/TP {}", DISCLAIMER))
.interact() .items(&multiselected[..])
.unwrap(); .defaults(&defaults[..])
.interact()
.unwrap();
}
// Keep only wanted courses // Keep only wanted courses
for day in &mut timetable.1 .1 { for day in &mut timetable.1 .1 {