Skip to content

Commit d21276a

Browse files
committed
Fix clippy violations
1 parent 7e2846f commit d21276a

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

wp_rs_cli/src/bin/wp_rs_cli/main.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ async fn resolve_post_id(client: &WpApiClient, post_url: &str) -> Result<PostId>
420420
let url = Url::parse(post_url).map_err(|e| anyhow!("Invalid url: {e}"))?;
421421
let slug_candidate = url
422422
.path_segments()
423-
.and_then(|segs| segs.filter(|s| !s.is_empty()).last())
423+
.and_then(|segs| segs.rev().find(|s| !s.is_empty()))
424424
.map(|s| s.trim_end_matches('/'))
425425
.unwrap_or("")
426426
.to_string();
@@ -431,11 +431,13 @@ async fn resolve_post_id(client: &WpApiClient, post_url: &str) -> Result<PostId>
431431

432432
// Query posts by slug; returns an array, take first match.
433433
// Using view context to ensure public content shape.
434-
let mut params = wp_api::posts::PostListParams::default();
435-
params.slug = vec![slug_candidate.clone()];
436-
params.per_page = Some(1);
434+
let params = wp_api::posts::PostListParams {
435+
slug: vec![slug_candidate.clone()],
436+
per_page: Some(1),
437+
..Default::default()
438+
};
437439
let resp = client.posts().list_with_view_context(&params).await?;
438-
if let Some(p) = resp.data.into_iter().find_map(|sp| Some(sp.id)) {
440+
if let Some(p) = resp.data.into_iter().map(|sp| sp.id).next() {
439441
return Ok(p);
440442
}
441443

0 commit comments

Comments
 (0)