From 9e840be8201cf83b30f240ef9f58a977eab3e8aa Mon Sep 17 00:00:00 2001
From: Awiteb
Date: Sat, 5 Jul 2025 09:34:32 +0000
Subject: [PATCH] chore: Use new stabilized `let-chains` feature
Signed-off-by: Awiteb
---
src/cli/config.rs | 9 +++++----
src/cli/mod.rs | 8 ++++----
src/nostr_utils/mod.rs | 24 ++++++++++++------------
src/nostr_utils/utils.rs | 8 ++++----
4 files changed, 25 insertions(+), 24 deletions(-)
diff --git a/src/cli/config.rs b/src/cli/config.rs
index ba3b20c..64b4341 100644
--- a/src/cli/config.rs
+++ b/src/cli/config.rs
@@ -89,11 +89,12 @@ impl CliConfig {
pub fn load(file_path: PathBuf) -> N34Result {
tracing::info!(path = %file_path.display(), "Loading configuration from file");
// Make sure the file is exist
- if let Some(parent) = file_path.parent() {
- if !parent.exists() {
- fs::create_dir_all(parent)?;
- }
+ if let Some(parent) = file_path.parent()
+ && !parent.exists()
+ {
+ fs::create_dir_all(parent)?;
}
+
let _ = fs::File::create_new(&file_path);
let mut config: Self =
diff --git a/src/cli/mod.rs b/src/cli/mod.rs
index 452bffc..c854282 100644
--- a/src/cli/mod.rs
+++ b/src/cli/mod.rs
@@ -82,10 +82,10 @@ impl Cli {
pub fn post_cli(mut cli: Cli) -> N34Result {
cli.options.pow = cli.options.pow.or(cli.options.config.pow);
- if cli.options.relays.is_empty() {
- if let Some(relays) = &cli.options.config.fallback_relays {
- cli.options.relays = relays.iter().cloned().map(RelayOrSet::Relay).collect();
- }
+ if cli.options.relays.is_empty()
+ && let Some(relays) = &cli.options.config.fallback_relays
+ {
+ cli.options.relays = relays.iter().cloned().map(RelayOrSet::Relay).collect();
}
Ok(cli)
diff --git a/src/nostr_utils/mod.rs b/src/nostr_utils/mod.rs
index 72af2e3..8bf8e04 100644
--- a/src/nostr_utils/mod.rs
+++ b/src/nostr_utils/mod.rs
@@ -314,16 +314,16 @@ impl NostrClient {
.map(|status| N34Result::Ok((PatchStatus::try_from(status.kind)?, status.tags)))
.unwrap_or_else(|| Ok((PatchStatus::Open, Tags::new())))?;
- if let Some(revision_id) = root_revision {
- if root_status.is_merged_or_applied()
- && !event_tags
- .filter(TagKind::e())
- .any(|t| t.is_reply() && t.content().is_some_and(|c| c == revision_id.to_hex()))
- {
- return Ok(PatchStatus::Closed);
- }
+ if let Some(revision_id) = root_revision
+ && root_status.is_merged_or_applied()
+ && !event_tags
+ .filter(TagKind::e())
+ .any(|t| t.is_reply() && t.content().is_some_and(|c| c == revision_id.to_hex()))
+ {
+ return Ok(PatchStatus::Closed);
}
+
Ok(root_status)
}
@@ -368,10 +368,10 @@ impl NostrClient {
{
self.add_relay_hint(relay_hint.cloned()).await;
let root_event = self.fetch_event(Filter::new().id(*id)).await?;
- if let Some(ref root_event) = root_event {
- if !matches!(root_event.kind, Kind::GitIssue | Kind::GitPatch) {
- return Err(N34Error::CanNotReplyToEvent);
- }
+ if let Some(ref root_event) = root_event
+ && !matches!(root_event.kind, Kind::GitIssue | Kind::GitPatch)
+ {
+ return Err(N34Error::CanNotReplyToEvent);
}
return Ok(root_event);
} else if let Some(nip22::CommentTarget::Event { id, relay_hint, .. }) =
diff --git a/src/nostr_utils/utils.rs b/src/nostr_utils/utils.rs
index 3b95ef3..f5bfbc0 100644
--- a/src/nostr_utils/utils.rs
+++ b/src/nostr_utils/utils.rs
@@ -207,10 +207,10 @@ pub fn read_editor(file_pre_content: Option<&str>, file_suffix: &str) -> N34Resu
.wait()?;
crate::EDITOR_OPEN.store(false, Ordering::Relaxed);
- if !exit_status.success() {
- if let Some(code) = exit_status.code() {
- return Err(N34Error::EditorErr(editor, code));
- }
+ if !exit_status.success()
+ && let Some(code) = exit_status.code()
+ {
+ return Err(N34Error::EditorErr(editor, code));
}
let content = fs::read_to_string(&temp_path)