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;
}
if let Some(pki_path) = &pki_path {
if !Path::is_file(pki_path) {
fail(stream);
return;
}
if let Some(pki_path) = &pki_path
&& !Path::is_file(pki_path)
{
fail(stream);
return;
}
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);
if let Ok(mut file) = File::create(file_paths.data) {
if to_stream::<PortableSettings, _, _>(&info, &mut file).is_err() {
eprintln!("Error saving data!");
eprintln!();
}
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 {

View File

@ -129,13 +129,13 @@ impl TabInfo {
let _ = writeln!(stream, "<h2>Description</h2>");
if let Some(audio_path) = &file_paths.audio {
if audio_path.is_file() {
let _ = writeln!(
stream,
"<p><audio controls src=\"/{relative_path}.mp3\"/></p>"
);
}
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);

View File

@ -507,36 +507,36 @@ 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) {
settings.change(change);
*state += 1;
}
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) {
for line in BufReader::new(file).lines() {
let Ok(line) = line else {
break;
};
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;
};
if let Some((channel, default_value)) = line.split_once(':') {
let _ = parser.add_new_channel(channel, default_value);
continue;
}
let line = line.trim();
if line.is_empty() {
continue;
}
return None;
if let Some((channel, default_value)) = line.split_once(':') {
let _ = parser.add_new_channel(channel, default_value);
continue;
}
let line = line.trim();
if line.is_empty() {
continue;
}
return None;
}
}
@ -601,10 +601,10 @@ 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)) {
choices.push((i, block))
}
if let Some(block) = dialog_sequence.blocks.first()
&& simulation.callable(Event(i))
{
choices.push((i, block))
}
}