refactor: apply clippy recos for rustc 1.98.0
This commit is contained in:
+28
@@ -0,0 +1,28 @@
|
||||
# Clippy configuration overrides. Kept minimal — each entry documents
|
||||
# what it's for and when it should be revisited.
|
||||
|
||||
# `clippy::result_large_err` — raise the "big Err variant" ceiling to
|
||||
# 512 bytes.
|
||||
#
|
||||
# Rationale: axum handler signatures shaped as
|
||||
# `Result<impl IntoResponse, impl IntoResponse>` (or `AppError` variants
|
||||
# that wrap `axum::response::Response`) naturally exceed the default
|
||||
# 128-byte threshold. `Response` carries a `HeaderMap` (~256 B inline)
|
||||
# + status + body + extensions; a handful of handlers land in that
|
||||
# range without doing anything wrong. Fighting the lint per-handler
|
||||
# with `#[allow]` on every one is churn for zero runtime benefit —
|
||||
# these Results are constructed on the stack once per request and
|
||||
# never nested in a hot inner loop.
|
||||
#
|
||||
# 512 B keeps the lint's protective value: it still fires on genuinely
|
||||
# oversized Err variants (embedded `Vec<u8>` blobs, avatar payloads,
|
||||
# large enum aggregates) that WOULD be worth boxing.
|
||||
#
|
||||
# Revisit if:
|
||||
# * A future refactor slims axum Response OR extracts a small error
|
||||
# enum with an IntoResponse impl across the handler layer — then
|
||||
# drop this override back to the default 128.
|
||||
# * A specific handler exceeds 512 B and clippy re-fires — deal with
|
||||
# that handler individually (boxed error / small enum) rather than
|
||||
# raising the ceiling further.
|
||||
large-error-threshold = 512
|
||||
@@ -43,9 +43,13 @@ fn stats(mut s: Vec<f64>) -> (f64, f64, f64) {
|
||||
|
||||
/// Mirror of `face_pg_repository::bytes_to_embedding` — the per-face
|
||||
/// `Vec<f32>` decode the BEFORE path pays for a column it never reads.
|
||||
/// Kept byte-for-byte identical to the shipped path so the benchmark
|
||||
/// measures apples-to-apples; `as_chunks` swap matches the source.
|
||||
fn bytes_to_embedding(b: &[u8]) -> Vec<f32> {
|
||||
b.chunks_exact(4)
|
||||
.map(|c| f32::from_le_bytes([c[0], c[1], c[2], c[3]]))
|
||||
b.as_chunks::<4>()
|
||||
.0
|
||||
.iter()
|
||||
.map(|c| f32::from_le_bytes(*c))
|
||||
.collect()
|
||||
}
|
||||
|
||||
|
||||
@@ -47,8 +47,17 @@ fn embedding_to_bytes(e: &[f32]) -> Vec<u8> {
|
||||
}
|
||||
|
||||
fn bytes_to_embedding(b: &[u8]) -> Vec<f32> {
|
||||
b.chunks_exact(4)
|
||||
.map(|c| f32::from_le_bytes([c[0], c[1], c[2], c[3]]))
|
||||
// `as_chunks::<4>` (stable since Rust 1.88) hands back `&[[u8; 4]]`
|
||||
// typed at the array level, so the closure gets a `&[u8; 4]` and
|
||||
// the `[c[0], c[1], c[2], c[3]]` array-copy dance from the old
|
||||
// `chunks_exact(4)` shape collapses to a plain deref. Any trailing
|
||||
// bytes that aren't a multiple of 4 land in `.1` and are dropped
|
||||
// — same semantics as `chunks_exact` which iterated only the
|
||||
// aligned prefix.
|
||||
b.as_chunks::<4>()
|
||||
.0
|
||||
.iter()
|
||||
.map(|c| f32::from_le_bytes(*c))
|
||||
.collect()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user