Section info not optional anymore

This commit is contained in:
p11 2025-05-30 00:22:58 +02:00
parent ce23dcf455
commit 81134d2007

View File

@ -651,10 +651,9 @@ fn handle_relative_connection(
Comment(Vec<Comment>), Comment(Vec<Comment>),
} }
#[derive(Default)]
struct Section { struct Section {
title: Box<str>, title: Box<str>,
info: Option<SectionInfo>, info: SectionInfo,
} }
let mut sections = Vec::new(); let mut sections = Vec::new();
@ -671,7 +670,7 @@ fn handle_relative_connection(
if let Some(config_map) = config_map { if let Some(config_map) = config_map {
sections.push(Section { sections.push(Section {
title: "Game".into(), title: "Game".into(),
info: Some(SectionInfo::Game(config_map)), info: SectionInfo::Game(config_map),
}); });
} else { } else {
let Ok(pk_file) = File::open(file_paths.pk) else { let Ok(pk_file) = File::open(file_paths.pk) else {
@ -689,7 +688,7 @@ fn handle_relative_connection(
if !current_title.is_empty() { if !current_title.is_empty() {
sections.push(Section { sections.push(Section {
title: current_title, title: current_title,
info: Some(SectionInfo::Lines(current_lines)), info: SectionInfo::Lines(current_lines),
}) })
} }
current_title = title.into(); current_title = title.into();
@ -703,20 +702,20 @@ fn handle_relative_connection(
sections.push(Section { sections.push(Section {
title: current_title, title: current_title,
info: Some(SectionInfo::Lines(current_lines)), info: SectionInfo::Lines(current_lines),
}) })
} }
if file_paths.pki.is_some() { if file_paths.pki.is_some() {
sections.push(Section { sections.push(Section {
title: "Description".into(), title: "Description".into(),
info: Some(SectionInfo::Description), info: SectionInfo::Description,
}); });
} }
sections.push(Section { sections.push(Section {
title: "Comments".into(), title: "Comments".into(),
info: Some(SectionInfo::Comment(comments)), info: SectionInfo::Comment(comments),
}); });
let count = sections.len(); let count = sections.len();
@ -802,7 +801,6 @@ fn handle_relative_connection(
for (i, Section { info, .. }) in sections.into_iter().enumerate() { for (i, Section { info, .. }) in sections.into_iter().enumerate() {
let index = i + 1; let index = i + 1;
let _ = write!(stream, r#"<div class="tab-content" id="content-{index}">"#); let _ = write!(stream, r#"<div class="tab-content" id="content-{index}">"#);
if let Some(info) = info {
match info { match info {
SectionInfo::Lines(lines) => { SectionInfo::Lines(lines) => {
convert_extended( convert_extended(
@ -878,7 +876,6 @@ fn handle_relative_connection(
} }
} }
} }
}
let _ = write!(stream, "</div>"); let _ = write!(stream, "</div>");
} }