Rust Idiom Cleanup

On this page

Status

COMPLETE — Delivered in MR !33, merged to main.

Context

A strict Rust idiom audit identified patterns across the codebase that can be tightened. All changes are mechanical and behavior-preserving.

Scope

Category Description Count Files

.unwrap().expect()

Add panic context to infallible unwraps in production code

6 sites

4 files

ApiError clone elimination

Change match &selfmatch self to move strings instead of cloning

3 clones

crates/craig-common/src/error.rs

SDK builder .to_string().into()

Use idiomatic conversion for &strString

26 methods

crates/craig-intake-sdk/src/types.rs

CLI .clone().to_owned()

Use idiomatic borrow-to-owned conversion

53 sites

18 CLI command files

CLI type annotation removal

Remove redundant Vec<(&str, String)> annotations

18 sites

Same 18 CLI files

Collection type simplification

Vec<ExplicitType>Vec<_> where inference suffices

3 sites

services/craig-intake/src/api/jws.rs

Out of Scope

  • 252× .map_err(|e| ApiError::Internal(e.to_string())) — too much churn for one MR; separate future work

  • 65× #[allow(dead_code)] — almost all legitimate (sqlx FromRow, Askama templates)

  • #[must_use] on builders — low value

  • Explicit return statements — audit found 0 problematic cases

Verification

  • All tests pass (no behavior changes)

  • cargo clippy clean

  • cargo fmt clean

Edit this page · latest