Collapsed some if-let-ifs

This commit is contained in:
p11 2025-08-09 21:48:54 +02:00
parent dad0adeb8c
commit 20b1290821
3 changed files with 43 additions and 43 deletions

View File

@ -385,12 +385,12 @@ fn handle_connection(
return;
}
if let Some(pki_path) = &pki_path {
if !Path::is_file(pki_path) {
if let Some(pki_path) = &pki_path
&& !Path::is_file(pki_path)
{
fail(stream);
return;
}
}
let info = if let Ok(mut context) = context.lock() {
use Entry::*;
@ -544,12 +544,12 @@ fn handle_relative_connection(
let info = info.update(name, text, up, down);
if let Ok(mut file) = File::create(file_paths.data) {
if to_stream::<PortableSettings, _, _>(&info, &mut file).is_err() {
if let Ok(mut file) = File::create(file_paths.data)
&& to_stream::<PortableSettings, _, _>(&info, &mut file).is_err()
{
eprintln!("Error saving data!");
eprintln!();
}
}
let SiteInfo {
comments,

View File

@ -129,14 +129,14 @@ impl TabInfo {
let _ = writeln!(stream, "<h2>Description</h2>");
if let Some(audio_path) = &file_paths.audio {
if audio_path.is_file() {
if let Some(audio_path) = &file_paths.audio
&& audio_path.is_file()
{
let _ = writeln!(
stream,
"<p><audio controls src=\"/{relative_path}.mp3\"/></p>"
);
}
}
let lines = BufReader::new(pki_file).lines().map_while(Result::ok);
convert_subheader(lines, stream, 1);

View File

@ -507,19 +507,20 @@ fn apply_block_changes(
.flat_map(|l| &l.actions)
.chain(&block.final_actions)
{
if let Some(state) = states.get_mut(parameter) {
if let Some(change) = changes[parameter].get(*state) {
if let Some(state) = states.get_mut(parameter)
&& let Some(change) = changes[parameter].get(*state)
{
settings.change(change);
*state += 1;
}
}
}
}
fn load_multilinear(mlc_path: Option<&Path>, mld_path: &Path) -> Option<NamedMultilinearInfo> {
let mut parser = MultilinearParser::default();
if let Some(mlc_path) = mlc_path {
if let Ok(file) = File::open(mlc_path) {
if let Some(mlc_path) = mlc_path
&& let Ok(file) = File::open(mlc_path)
{
for line in BufReader::new(file).lines() {
let Ok(line) = line else {
break;
@ -538,7 +539,6 @@ fn load_multilinear(mlc_path: Option<&Path>, mld_path: &Path) -> Option<NamedMul
return None;
}
}
}
if let Err(e) = parser.parse(File::open(mld_path).ok()?, &[]) {
eprintln!("Error parsing multilinear definition: {e}");
@ -601,12 +601,12 @@ pub fn render_novel(
let mut choices = Vec::new();
for (i, dialog_sequence) in dialogs.iter().enumerate() {
if let Some(block) = dialog_sequence.blocks.first() {
if simulation.callable(Event(i)) {
if let Some(block) = dialog_sequence.blocks.first()
&& simulation.callable(Event(i))
{
choices.push((i, block))
}
}
}
if choices.len() == 1 {
let next_choice = choices[0].0;