Skip to content

refactor(project_prompt): replace is_some/is_none+unwrap with let-Some / match (#196, #197)#247

Closed
SAY-5 wants to merge 2 commits intoTrueNine:devfrom
SAY-5:refactor/project-prompt-let-else-196-197
Closed

refactor(project_prompt): replace is_some/is_none+unwrap with let-Some / match (#196, #197)#247
SAY-5 wants to merge 2 commits intoTrueNine:devfrom
SAY-5:refactor/project-prompt-let-else-196-197

Conversation

@SAY-5
Copy link
Copy Markdown
Contributor

@SAY-5 SAY-5 commented Apr 29, 2026

Closes #196.
Closes #197.

Two adjacent unwrap-anti-patterns in enhance_workspace_projects_with_aindex:

  • L301-302 ([Project Prompt] is_some() 后直接 unwrap() 反模式 #196): if project.project_type.is_some() { vec![project.project_type.clone().unwrap()] }match &project.project_type { Some(ptype) => vec![ptype.clone()], None => … }. Removes the redundant is_some(), drops the unwrap(), and clones only the borrow we actually need.
  • L307-319 ([Project Prompt] is_none()+continue 后 unwrap() 反模式 #197): let matching_series = find(…); if matching_series.is_none() { continue }; let series_name = matching_series.unwrap();let Some(series_name) = find(…) else { … continue };. Single binding, no redundant is_none() re-check, no unwrap() on a path that already proved Some.

Behaviour is identical; the change is purely an idiom cleanup.

Test plan

  • cargo build --manifest-path sdk/Cargo.toml — clean
  • cargo test --manifest-path sdk/Cargo.toml --lib repositories — 45/45 pass

TrueNine and others added 2 commits April 25, 2026 10:10
Fix two CI failures from previous merge
…ome / match

Closes TrueNine#196.
Closes TrueNine#197.

Two adjacent unwrap-anti-patterns in
`enhance_workspace_projects_with_aindex`:

- L301-302: `if project.project_type.is_some() { vec![project.project_type.clone().unwrap()] }`
  → `match &project.project_type { Some(ptype) => vec![ptype.clone()], None => … }`
  Removes the redundant `is_some()` check, drops the `unwrap()`,
  and clones only the borrow we actually need (TrueNine#196).

- L307-319: `let matching_series = …find(…); if matching_series.is_none() { continue }; let series_name = matching_series.unwrap();`
  → `let Some(series_name) = …find(…) else { … continue }; …`
  Single binding, no redundant `is_none()` re-check, no `unwrap()` on
  the path that already proved `Some` (TrueNine#197).

Behaviour is identical; the change is purely an idiom cleanup. The
existing `repositories::project_prompt` test coverage (rolled into
the 45-test `repositories` suite) stays green.
@SAY-5 SAY-5 requested a review from TrueNine as a code owner April 29, 2026 22:55
@TrueNine TrueNine changed the base branch from main to dev April 30, 2026 08:08
@TrueNine
Copy link
Copy Markdown
Owner

Merged into dev via cherry-pick. The PR base was changed from main to dev, which caused conflicts because dev had diverged significantly. All commits have been cherry-picked onto dev and pushed. Thanks for the contributions!

@TrueNine TrueNine closed this Apr 30, 2026
@TrueNine
Copy link
Copy Markdown
Owner

Thank you for the contribution! All commits have been cherry-picked and merged into the dev branch. 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Project Prompt] is_none()+continue 后 unwrap() 反模式 [Project Prompt] is_some() 后直接 unwrap() 反模式

2 participants