Rust: small departures from the style guide (imports, unwrap, for headers, must_use, bool parameters, SAFETY) #353

Closed
opened 2026-10-23 18:00:02 -07:00 by rays · 1 comment
Owner

Measured against /src/styleguide/rustguide.md (2026-10-24):

  • 3 use lines mix paths in their braces (directory/src/main.rs:5, ipx/src/auth.rs:7, ipx/src/metrics.rs:11), and free functions are imported bare (db::{now, step}, tokio::signal::unix::signal) where the guide calls them through their module.
  • The one unsafe (a test's set_var, ipx/src/config.rs) has no SAFETY: comment.
  • About 30 unwrap() outside tests, 24 of them .lock().unwrap(), where the guide prefers expect saying why.
  • 27 for loops build a combinator chain in their header.
  • 27 functions clippy's must_use_candidate names.
  • About 8 bool parameters whose meaning the call does not show: Db::open(url, true), reap(ctx, dry_run, standalone), serve_media(.., piece), log_event(e, wire), Emitter::socket(tx, print).
Measured against /src/styleguide/rustguide.md (2026-10-24): - 3 `use` lines mix paths in their braces (directory/src/main.rs:5, ipx/src/auth.rs:7, ipx/src/metrics.rs:11), and free functions are imported bare (`db::{now, step}`, `tokio::signal::unix::signal`) where the guide calls them through their module. - The one `unsafe` (a test's `set_var`, ipx/src/config.rs) has no `SAFETY:` comment. - About 30 `unwrap()` outside tests, 24 of them `.lock().unwrap()`, where the guide prefers `expect` saying why. - 27 `for` loops build a combinator chain in their header. - 27 functions clippy's must_use_candidate names. - About 8 `bool` parameters whose meaning the call does not show: `Db::open(url, true)`, `reap(ctx, dry_run, standalone)`, `serve_media(.., piece)`, `log_event(e, wire)`, `Emitter::socket(tx, print)`.
rays added the enhancement label 2026-10-23 18:00:02 -07:00
Author
Owner

Done in 41affc8: use statements import from one module and free functions go through theirs; unsafe_code is forbidden workspace-wide (the one unsafe, a test's set_var, is gone); lock unwraps are expects saying why; no combinator chains in for headers; #[must_use] on clippy's 27 candidates; literal bools at unclear call sites carry their name. No behaviour change. Tests (feed 40, directory 23, ipx 151) and clippy pass.

Done in 41affc8: use statements import from one module and free functions go through theirs; unsafe_code is forbidden workspace-wide (the one unsafe, a test's set_var, is gone); lock unwraps are expects saying why; no combinator chains in for headers; #[must_use] on clippy's 27 candidates; literal bools at unclear call sites carry their name. No behaviour change. Tests (feed 40, directory 23, ipx 151) and clippy pass.
rays closed this issue 2026-10-23 18:07:23 -07:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: rays/ipx#353