From 0f824635d1637c5abb5128ae42e9d40da43b9fc1 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 13 Jul 2026 08:24:31 +0000 Subject: [PATCH] =?UTF-8?q?chore(clippy):=20appease=201.97=20lints=20?= =?UTF-8?q?=E2=80=94=20derive=20Default,=20collapse=20ifs,=20drop=20needle?= =?UTF-8?q?ss=20borrow?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Pre-existing, surfaced by the toolchain bump (rust-version is 1.95; the sandbox gates with stable 1.97). All four are cargo clippy --fix output with the mechanical-collapse indentation hand-tidied to house style; the parser change is semantics-preserving (a non-100-continue Expect value now falls to the _ arm instead of an empty if — headers.append still runs after the match either way). No fmt pass: rustfmt would clobber the aligned-assignment style, so only the touched lines moved. --- examples/ws_chat.rs | 2 +- src/conn.rs | 6 ++---- src/conn_actor.rs | 8 ++++---- src/parser.rs | 6 ++---- 4 files changed, 9 insertions(+), 13 deletions(-) diff --git a/examples/ws_chat.rs b/examples/ws_chat.rs index 841b773..975ffaa 100644 --- a/examples/ws_chat.rs +++ b/examples/ws_chat.rs @@ -92,7 +92,7 @@ impl WsHandler for ChatHandler { // subscribed as. let _ = self .bus() - .broadcast_from(smarm::self_pid(), &self.topic(), text); + .broadcast_from(smarm::self_pid(), self.topic(), text); } fn on_close(&mut self, _code: Option, _reason: &str) { diff --git a/src/conn.rs b/src/conn.rs index 46460c8..06e8486 100644 --- a/src/conn.rs +++ b/src/conn.rs @@ -158,7 +158,9 @@ impl Body { // Empty `Vec`s are skipped by the pump (a zero-length chunk would // terminate chunked framing early), so they are safe to send but useless. +#[derive(Default)] pub enum RespBody { + #[default] Empty, Bytes(Vec), Stream(StreamBody), @@ -217,10 +219,6 @@ impl RespBody { } } -impl Default for RespBody { - fn default() -> Self { RespBody::Empty } -} - // --------------------------------------------------------------------------- // Params — path parameters extracted by the router. // --------------------------------------------------------------------------- diff --git a/src/conn_actor.rs b/src/conn_actor.rs index c51eb2b..e95e040 100644 --- a/src/conn_actor.rs +++ b/src/conn_actor.rs @@ -157,10 +157,10 @@ pub fn run_connection( // If client sent `Expect: 100-continue`, emit it before reading the // body. RFC 7231 §5.1.1. We don't gate on app logic here; v1 always // accepts. - if parsed.expect_100 { - if write_all(raw, b"HTTP/1.1 100 Continue\r\n\r\n", Instant::now() + limits.write_timeout).is_err() { - return; - } + if parsed.expect_100 + && write_all(raw, b"HTTP/1.1 100 Continue\r\n\r\n", Instant::now() + limits.write_timeout).is_err() + { + return; } // `consumed_past_head`: how many RAW bytes of `buf` past the head diff --git a/src/parser.rs b/src/parser.rs index 06dff0c..65ab7a4 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -123,10 +123,8 @@ pub fn parse_head(buf: &[u8], max_headers: usize) -> Result { connection_hdr = Some(value.to_ascii_lowercase()); } - "expect" => { - if value.eq_ignore_ascii_case("100-continue") { - expect_100 = true; - } + "expect" if value.eq_ignore_ascii_case("100-continue") => { + expect_100 = true; } _ => {} }