Improve value and reference passing efficiency (#3406)

This commit is contained in:
Theodore Bjernhed
2025-07-11 05:38:45 +02:00
committed by GitHub
parent 420d7b6aaa
commit 6bc0717b06
17 changed files with 117 additions and 107 deletions
+2 -2
View File
@@ -206,7 +206,7 @@ impl IntoResponseParts for CookieJar {
type Error = Infallible;
fn into_response_parts(self, mut res: ResponseParts) -> Result<ResponseParts, Self::Error> {
set_cookies(self.jar, res.headers_mut());
set_cookies(&self.jar, res.headers_mut());
Ok(res)
}
}
@@ -217,7 +217,7 @@ impl IntoResponse for CookieJar {
}
}
fn set_cookies(jar: cookie::CookieJar, headers: &mut HeaderMap) {
fn set_cookies(jar: &cookie::CookieJar, headers: &mut HeaderMap) {
for cookie in jar.delta() {
if let Ok(header_value) = cookie.encoded().to_string().parse() {
headers.append(SET_COOKIE, header_value);
+1 -1
View File
@@ -274,7 +274,7 @@ impl<K> IntoResponseParts for PrivateCookieJar<K> {
type Error = Infallible;
fn into_response_parts(self, mut res: ResponseParts) -> Result<ResponseParts, Self::Error> {
set_cookies(self.jar, res.headers_mut());
set_cookies(&self.jar, res.headers_mut());
Ok(res)
}
}
+1 -1
View File
@@ -292,7 +292,7 @@ impl<K> IntoResponseParts for SignedCookieJar<K> {
type Error = Infallible;
fn into_response_parts(self, mut res: ResponseParts) -> Result<ResponseParts, Self::Error> {
set_cookies(self.jar, res.headers_mut());
set_cookies(&self.jar, res.headers_mut());
Ok(res)
}
}
+3 -5
View File
@@ -172,7 +172,7 @@ mod tests {
let app = Router::new().route(
"/",
post(|input: Protobuf<Input>| async move { input.foo.to_owned() }),
post(|Protobuf(input): Protobuf<Input>| async move { input.foo }),
);
let input = Input {
@@ -228,10 +228,8 @@ mod tests {
}
#[axum::debug_handler]
async fn handler(input: Protobuf<Input>) -> Protobuf<Output> {
let output = Output {
result: input.foo.to_owned(),
};
async fn handler(Protobuf(input): Protobuf<Input>) -> Protobuf<Output> {
let output = Output { result: input.foo };
Protobuf(output)
}