chore(clippy): appease 1.97 lints — derive Default, collapse ifs, drop needless borrow
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.
This commit is contained in:
+1
-1
@@ -92,7 +92,7 @@ impl WsHandler for ChatHandler {
|
|||||||
// subscribed as.
|
// subscribed as.
|
||||||
let _ = self
|
let _ = self
|
||||||
.bus()
|
.bus()
|
||||||
.broadcast_from(smarm::self_pid(), &self.topic(), text);
|
.broadcast_from(smarm::self_pid(), self.topic(), text);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn on_close(&mut self, _code: Option<u16>, _reason: &str) {
|
fn on_close(&mut self, _code: Option<u16>, _reason: &str) {
|
||||||
|
|||||||
+2
-4
@@ -158,7 +158,9 @@ impl Body {
|
|||||||
// Empty `Vec`s are skipped by the pump (a zero-length chunk would
|
// 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.
|
// terminate chunked framing early), so they are safe to send but useless.
|
||||||
|
|
||||||
|
#[derive(Default)]
|
||||||
pub enum RespBody {
|
pub enum RespBody {
|
||||||
|
#[default]
|
||||||
Empty,
|
Empty,
|
||||||
Bytes(Vec<u8>),
|
Bytes(Vec<u8>),
|
||||||
Stream(StreamBody),
|
Stream(StreamBody),
|
||||||
@@ -217,10 +219,6 @@ impl RespBody {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for RespBody {
|
|
||||||
fn default() -> Self { RespBody::Empty }
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
// Params — path parameters extracted by the router.
|
// Params — path parameters extracted by the router.
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|||||||
+3
-3
@@ -157,11 +157,11 @@ pub fn run_connection(
|
|||||||
// If client sent `Expect: 100-continue`, emit it before reading the
|
// 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
|
// body. RFC 7231 §5.1.1. We don't gate on app logic here; v1 always
|
||||||
// accepts.
|
// accepts.
|
||||||
if parsed.expect_100 {
|
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() {
|
&& write_all(raw, b"HTTP/1.1 100 Continue\r\n\r\n", Instant::now() + limits.write_timeout).is_err()
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// `consumed_past_head`: how many RAW bytes of `buf` past the head
|
// `consumed_past_head`: how many RAW bytes of `buf` past the head
|
||||||
// this request's body occupied — for chunked bodies that is framing
|
// this request's body occupied — for chunked bodies that is framing
|
||||||
|
|||||||
+1
-3
@@ -123,11 +123,9 @@ pub fn parse_head(buf: &[u8], max_headers: usize) -> Result<ParsedHead, ParseErr
|
|||||||
"connection" => {
|
"connection" => {
|
||||||
connection_hdr = Some(value.to_ascii_lowercase());
|
connection_hdr = Some(value.to_ascii_lowercase());
|
||||||
}
|
}
|
||||||
"expect" => {
|
"expect" if value.eq_ignore_ascii_case("100-continue") => {
|
||||||
if value.eq_ignore_ascii_case("100-continue") {
|
|
||||||
expect_100 = true;
|
expect_100 = true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
headers.append(&name_lower, value.to_string());
|
headers.append(&name_lower, value.to_string());
|
||||||
|
|||||||
Reference in New Issue
Block a user