chore: Use new stabilized let-chains feature

Signed-off-by: Awiteb <a@4rs.nl>
This commit is contained in:
Awiteb
2025-07-05 09:34:32 +00:00
parent 3fb7abe62a
commit 9e840be820
4 changed files with 25 additions and 24 deletions

View File

@@ -89,11 +89,12 @@ impl CliConfig {
pub fn load(file_path: PathBuf) -> N34Result<Self> { pub fn load(file_path: PathBuf) -> N34Result<Self> {
tracing::info!(path = %file_path.display(), "Loading configuration from file"); tracing::info!(path = %file_path.display(), "Loading configuration from file");
// Make sure the file is exist // Make sure the file is exist
if let Some(parent) = file_path.parent() { if let Some(parent) = file_path.parent()
if !parent.exists() { && !parent.exists()
{
fs::create_dir_all(parent)?; fs::create_dir_all(parent)?;
} }
}
let _ = fs::File::create_new(&file_path); let _ = fs::File::create_new(&file_path);
let mut config: Self = let mut config: Self =

View File

@@ -82,11 +82,11 @@ impl Cli {
pub fn post_cli(mut cli: Cli) -> N34Result<Cli> { pub fn post_cli(mut cli: Cli) -> N34Result<Cli> {
cli.options.pow = cli.options.pow.or(cli.options.config.pow); cli.options.pow = cli.options.pow.or(cli.options.config.pow);
if cli.options.relays.is_empty() { if cli.options.relays.is_empty()
if let Some(relays) = &cli.options.config.fallback_relays { && let Some(relays) = &cli.options.config.fallback_relays
{
cli.options.relays = relays.iter().cloned().map(RelayOrSet::Relay).collect(); cli.options.relays = relays.iter().cloned().map(RelayOrSet::Relay).collect();
} }
}
Ok(cli) Ok(cli)
} }

View File

@@ -314,15 +314,15 @@ impl NostrClient {
.map(|status| N34Result::Ok((PatchStatus::try_from(status.kind)?, status.tags))) .map(|status| N34Result::Ok((PatchStatus::try_from(status.kind)?, status.tags)))
.unwrap_or_else(|| Ok((PatchStatus::Open, Tags::new())))?; .unwrap_or_else(|| Ok((PatchStatus::Open, Tags::new())))?;
if let Some(revision_id) = root_revision { if let Some(revision_id) = root_revision
if root_status.is_merged_or_applied() && root_status.is_merged_or_applied()
&& !event_tags && !event_tags
.filter(TagKind::e()) .filter(TagKind::e())
.any(|t| t.is_reply() && t.content().is_some_and(|c| c == revision_id.to_hex())) .any(|t| t.is_reply() && t.content().is_some_and(|c| c == revision_id.to_hex()))
{ {
return Ok(PatchStatus::Closed); return Ok(PatchStatus::Closed);
} }
}
Ok(root_status) Ok(root_status)
} }
@@ -368,11 +368,11 @@ impl NostrClient {
{ {
self.add_relay_hint(relay_hint.cloned()).await; self.add_relay_hint(relay_hint.cloned()).await;
let root_event = self.fetch_event(Filter::new().id(*id)).await?; let root_event = self.fetch_event(Filter::new().id(*id)).await?;
if let Some(ref root_event) = root_event { if let Some(ref root_event) = root_event
if !matches!(root_event.kind, Kind::GitIssue | Kind::GitPatch) { && !matches!(root_event.kind, Kind::GitIssue | Kind::GitPatch)
{
return Err(N34Error::CanNotReplyToEvent); return Err(N34Error::CanNotReplyToEvent);
} }
}
return Ok(root_event); return Ok(root_event);
} else if let Some(nip22::CommentTarget::Event { id, relay_hint, .. }) = } else if let Some(nip22::CommentTarget::Event { id, relay_hint, .. }) =
nip22::extract_parent(&event) nip22::extract_parent(&event)

View File

@@ -207,11 +207,11 @@ pub fn read_editor(file_pre_content: Option<&str>, file_suffix: &str) -> N34Resu
.wait()?; .wait()?;
crate::EDITOR_OPEN.store(false, Ordering::Relaxed); crate::EDITOR_OPEN.store(false, Ordering::Relaxed);
if !exit_status.success() { if !exit_status.success()
if let Some(code) = exit_status.code() { && let Some(code) = exit_status.code()
{
return Err(N34Error::EditorErr(editor, code)); return Err(N34Error::EditorErr(editor, code));
} }
}
let content = fs::read_to_string(&temp_path) let content = fs::read_to_string(&temp_path)
.map_err(N34Error::from)? .map_err(N34Error::from)?