Replaced if-let-else-unreachable with let-else-unreachable
This commit is contained in:
parent
58d02c86e2
commit
605b29ddfb
184
src/main.rs
184
src/main.rs
@ -566,118 +566,118 @@ fn handle_relative_connection(
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Ok(pk_file) = File::open(file_paths.pk) {
|
let Ok(pk_file) = File::open(file_paths.pk) else {
|
||||||
let lines = BufReader::new(pk_file).lines();
|
unreachable!();
|
||||||
|
};
|
||||||
|
|
||||||
if let Some(i) = partial {
|
let lines = BufReader::new(pk_file).lines();
|
||||||
let mut last_empty = true;
|
|
||||||
let mut block = 0;
|
|
||||||
let lines: Vec<_> = lines.map(Result::unwrap_or_default).collect();
|
|
||||||
let mut lines = lines.into_iter();
|
|
||||||
if i > 0 {
|
|
||||||
for line in lines.by_ref() {
|
|
||||||
let empty = line.trim().is_empty();
|
|
||||||
if empty == last_empty {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if empty {
|
|
||||||
block += 1;
|
|
||||||
if block == i {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
last_empty = empty;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for line in lines.clone() {
|
if let Some(i) = partial {
|
||||||
|
let mut last_empty = true;
|
||||||
|
let mut block = 0;
|
||||||
|
let lines: Vec<_> = lines.map(Result::unwrap_or_default).collect();
|
||||||
|
let mut lines = lines.into_iter();
|
||||||
|
if i > 0 {
|
||||||
|
for line in lines.by_ref() {
|
||||||
let empty = line.trim().is_empty();
|
let empty = line.trim().is_empty();
|
||||||
if empty == last_empty {
|
if empty == last_empty {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if empty {
|
if empty {
|
||||||
block += 1;
|
block += 1;
|
||||||
|
if block == i {
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
last_empty = empty;
|
last_empty = empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
let _ = writeln!(stream, "<h1>{title} ({}/{})</h1>", i + 1, block);
|
|
||||||
|
|
||||||
let _ = writeln!(
|
|
||||||
stream,
|
|
||||||
"<a href=\"/{relative_path}\">< Stop ></a><br><br>"
|
|
||||||
);
|
|
||||||
if i > 0 {
|
|
||||||
let prev = i - 1;
|
|
||||||
let _ = writeln!(stream, "<a href=\"/{relative_path}={prev}\">< Prev</a>");
|
|
||||||
} else {
|
|
||||||
let _ = writeln!(stream, "<font color=\"gray\">< Prev</font>");
|
|
||||||
}
|
|
||||||
|
|
||||||
if i + 1 < block {
|
|
||||||
let next = i + 1;
|
|
||||||
let _ = writeln!(stream, "<a href=\"/{relative_path}={next}\">Next ></a>");
|
|
||||||
} else {
|
|
||||||
let _ = writeln!(stream, "<font color=\"gray\">Next ></font>");
|
|
||||||
}
|
|
||||||
|
|
||||||
let _ = writeln!(stream, "<br>");
|
|
||||||
|
|
||||||
let mut has_text = false;
|
|
||||||
convert_extended(
|
|
||||||
lines.take_while(|line| {
|
|
||||||
let empty = line.trim().is_empty();
|
|
||||||
if !empty {
|
|
||||||
has_text = true;
|
|
||||||
}
|
|
||||||
!empty || !has_text
|
|
||||||
}),
|
|
||||||
&mut stream,
|
|
||||||
Settings::default()
|
|
||||||
.with_handler(handle_entry)
|
|
||||||
.with_start_level(start_level)
|
|
||||||
.with_use_textboxes(true),
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
if !title.is_empty() {
|
|
||||||
let _ = writeln!(stream, "<h1>{title}</h1>");
|
|
||||||
}
|
|
||||||
let _ = writeln!(stream, "<a href=\"/{relative_path}=0\">< Play ></a>");
|
|
||||||
convert_extended(
|
|
||||||
lines.map(Result::unwrap_or_default),
|
|
||||||
&mut stream,
|
|
||||||
Settings::default()
|
|
||||||
.with_handler(handle_entry)
|
|
||||||
.with_start_level(start_level)
|
|
||||||
.with_use_textboxes(true),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for line in lines.clone() {
|
||||||
|
let empty = line.trim().is_empty();
|
||||||
|
if empty == last_empty {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if empty {
|
||||||
|
block += 1;
|
||||||
|
}
|
||||||
|
last_empty = empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
let _ = writeln!(stream, "<h1>{title} ({}/{})</h1>", i + 1, block);
|
||||||
|
|
||||||
|
let _ = writeln!(
|
||||||
|
stream,
|
||||||
|
"<a href=\"/{relative_path}\">< Stop ></a><br><br>"
|
||||||
|
);
|
||||||
|
if i > 0 {
|
||||||
|
let prev = i - 1;
|
||||||
|
let _ = writeln!(stream, "<a href=\"/{relative_path}={prev}\">< Prev</a>");
|
||||||
|
} else {
|
||||||
|
let _ = writeln!(stream, "<font color=\"gray\">< Prev</font>");
|
||||||
|
}
|
||||||
|
|
||||||
|
if i + 1 < block {
|
||||||
|
let next = i + 1;
|
||||||
|
let _ = writeln!(stream, "<a href=\"/{relative_path}={next}\">Next ></a>");
|
||||||
|
} else {
|
||||||
|
let _ = writeln!(stream, "<font color=\"gray\">Next ></font>");
|
||||||
|
}
|
||||||
|
|
||||||
|
let _ = writeln!(stream, "<br>");
|
||||||
|
|
||||||
|
let mut has_text = false;
|
||||||
|
convert_extended(
|
||||||
|
lines.take_while(|line| {
|
||||||
|
let empty = line.trim().is_empty();
|
||||||
|
if !empty {
|
||||||
|
has_text = true;
|
||||||
|
}
|
||||||
|
!empty || !has_text
|
||||||
|
}),
|
||||||
|
&mut stream,
|
||||||
|
Settings::default()
|
||||||
|
.with_handler(handle_entry)
|
||||||
|
.with_start_level(start_level)
|
||||||
|
.with_use_textboxes(true),
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
unreachable!();
|
if !title.is_empty() {
|
||||||
|
let _ = writeln!(stream, "<h1>{title}</h1>");
|
||||||
|
}
|
||||||
|
let _ = writeln!(stream, "<a href=\"/{relative_path}=0\">< Play ></a>");
|
||||||
|
convert_extended(
|
||||||
|
lines.map(Result::unwrap_or_default),
|
||||||
|
&mut stream,
|
||||||
|
Settings::default()
|
||||||
|
.with_handler(handle_entry)
|
||||||
|
.with_start_level(start_level)
|
||||||
|
.with_use_textboxes(true),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
section(&mut stream);
|
section(&mut stream);
|
||||||
|
|
||||||
if let Some(pki_path) = file_paths.pki {
|
if let Some(pki_path) = file_paths.pki {
|
||||||
if let Ok(pki_file) = File::open(pki_path) {
|
let Ok(pki_file) = File::open(pki_path) else {
|
||||||
let _ = writeln!(stream, "<h1>Description</h1>");
|
|
||||||
|
|
||||||
if let Some(audio_path) = &file_paths.audio {
|
|
||||||
if Path::is_file(audio_path) {
|
|
||||||
let _ = writeln!(
|
|
||||||
stream,
|
|
||||||
"<p><audio controls src=\"/{relative_path}.mp3\"/></p>"
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let lines = BufReader::new(pki_file).lines();
|
|
||||||
convert_subheader(lines.map(Result::unwrap_or_default), &mut stream, 1);
|
|
||||||
|
|
||||||
section(&mut stream);
|
|
||||||
} else {
|
|
||||||
unreachable!();
|
unreachable!();
|
||||||
|
};
|
||||||
|
|
||||||
|
let _ = writeln!(stream, "<h1>Description</h1>");
|
||||||
|
|
||||||
|
if let Some(audio_path) = &file_paths.audio {
|
||||||
|
if Path::is_file(audio_path) {
|
||||||
|
let _ = writeln!(
|
||||||
|
stream,
|
||||||
|
"<p><audio controls src=\"/{relative_path}.mp3\"/></p>"
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let lines = BufReader::new(pki_file).lines();
|
||||||
|
convert_subheader(lines.map(Result::unwrap_or_default), &mut stream, 1);
|
||||||
|
|
||||||
|
section(&mut stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
let html = html! {
|
let html = html! {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user