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

View File

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

View File

@ -507,36 +507,36 @@ fn apply_block_changes(
.flat_map(|l| &l.actions) .flat_map(|l| &l.actions)
.chain(&block.final_actions) .chain(&block.final_actions)
{ {
if let Some(state) = states.get_mut(parameter) { if let Some(state) = states.get_mut(parameter)
if let Some(change) = changes[parameter].get(*state) { && let Some(change) = changes[parameter].get(*state)
settings.change(change); {
*state += 1; settings.change(change);
} *state += 1;
} }
} }
} }
fn load_multilinear(mlc_path: Option<&Path>, mld_path: &Path) -> Option<NamedMultilinearInfo> { fn load_multilinear(mlc_path: Option<&Path>, mld_path: &Path) -> Option<NamedMultilinearInfo> {
let mut parser = MultilinearParser::default(); let mut parser = MultilinearParser::default();
if let Some(mlc_path) = mlc_path { if let Some(mlc_path) = mlc_path
if let Ok(file) = File::open(mlc_path) { && let Ok(file) = File::open(mlc_path)
for line in BufReader::new(file).lines() { {
let Ok(line) = line else { for line in BufReader::new(file).lines() {
break; let Ok(line) = line else {
}; break;
};
if let Some((channel, default_value)) = line.split_once(':') { if let Some((channel, default_value)) = line.split_once(':') {
let _ = parser.add_new_channel(channel, default_value); let _ = parser.add_new_channel(channel, default_value);
continue; continue;
}
let line = line.trim();
if line.is_empty() {
continue;
}
return None;
} }
let line = line.trim();
if line.is_empty() {
continue;
}
return None;
} }
} }
@ -601,10 +601,10 @@ pub fn render_novel(
let mut choices = Vec::new(); let mut choices = Vec::new();
for (i, dialog_sequence) in dialogs.iter().enumerate() { for (i, dialog_sequence) in dialogs.iter().enumerate() {
if let Some(block) = dialog_sequence.blocks.first() { if let Some(block) = dialog_sequence.blocks.first()
if simulation.callable(Event(i)) { && simulation.callable(Event(i))
choices.push((i, block)) {
} choices.push((i, block))
} }
} }