Rust: small departures from the style guide (imports, unwrap, for headers, must_use, bool parameters, SAFETY) #353
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Measured against /src/styleguide/rustguide.md (2026-10-24):
uselines 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.unsafe(a test'sset_var, ipx/src/config.rs) has noSAFETY:comment.unwrap()outside tests, 24 of them.lock().unwrap(), where the guide prefersexpectsaying why.forloops build a combinator chain in their header.boolparameters 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).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.