mirror of
https://github.com/tokio-rs/axum.git
synced 2026-09-07 00:00:12 +02:00
Make clippy happy (#3350)
This commit is contained in:
@@ -33,7 +33,6 @@ inefficient_to_string = "warn"
|
|||||||
linkedlist = "warn"
|
linkedlist = "warn"
|
||||||
lossy_float_literal = "warn"
|
lossy_float_literal = "warn"
|
||||||
macro_use_imports = "warn"
|
macro_use_imports = "warn"
|
||||||
match_on_vec_items = "warn"
|
|
||||||
match_wildcard_for_single_variants = "warn"
|
match_wildcard_for_single_variants = "warn"
|
||||||
mem_forget = "warn"
|
mem_forget = "warn"
|
||||||
needless_borrow = "warn"
|
needless_borrow = "warn"
|
||||||
|
|||||||
@@ -775,10 +775,11 @@ fn impl_struct_by_extracting_all_at_once(
|
|||||||
.chain(via_marker_type)
|
.chain(via_marker_type)
|
||||||
.collect::<Punctuated<Type, Token![,]>>();
|
.collect::<Punctuated<Type, Token![,]>>();
|
||||||
|
|
||||||
let ident_generics = generic_ident
|
let ident_generics = if generic_ident.is_some() {
|
||||||
.is_some()
|
quote! { <T> }
|
||||||
.then(|| quote! { <T> })
|
} else {
|
||||||
.unwrap_or_default();
|
TokenStream::new()
|
||||||
|
};
|
||||||
|
|
||||||
let rejection_bound = rejection.as_ref().map(|rejection| {
|
let rejection_bound = rejection.as_ref().map(|rejection| {
|
||||||
match (tr, generic_ident.is_some()) {
|
match (tr, generic_ident.is_some()) {
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ async fn main() {
|
|||||||
.with_upgrades()
|
.with_upgrades()
|
||||||
.await
|
.await
|
||||||
{
|
{
|
||||||
println!("Failed to serve connection: {:?}", err);
|
println!("Failed to serve connection: {err:?}");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ async fn handler(State(client): State<Client>, mut req: Request) -> Result<Respo
|
|||||||
.map(|v| v.as_str())
|
.map(|v| v.as_str())
|
||||||
.unwrap_or(path);
|
.unwrap_or(path);
|
||||||
|
|
||||||
let uri = format!("http://127.0.0.1:3000{}", path_query);
|
let uri = format!("http://127.0.0.1:3000{path_query}");
|
||||||
|
|
||||||
*req.uri_mut() = Uri::try_from(uri).unwrap();
|
*req.uri_mut() = Uri::try_from(uri).unwrap();
|
||||||
|
|
||||||
|
|||||||
@@ -85,19 +85,19 @@ mod tests {
|
|||||||
async fn spawn_app(host: impl Into<String>) -> String {
|
async fn spawn_app(host: impl Into<String>) -> String {
|
||||||
let host = host.into();
|
let host = host.into();
|
||||||
// Bind to localhost at the port 0, which will let the OS assign an available port to us
|
// Bind to localhost at the port 0, which will let the OS assign an available port to us
|
||||||
let listener = TcpListener::bind(format!("{}:0", host)).await.unwrap();
|
let listener = TcpListener::bind(format!("{host}:0")).await.unwrap();
|
||||||
// Retrieve the port assigned to us by the OS
|
// Retrieve the port assigned to us by the OS
|
||||||
let port = listener.local_addr().unwrap().port();
|
let port = listener.local_addr().unwrap().port();
|
||||||
tokio::spawn(async {
|
tokio::spawn(async {
|
||||||
axum::serve(listener, app()).await.unwrap();
|
axum::serve(listener, app()).await.unwrap();
|
||||||
});
|
});
|
||||||
// Returns address (e.g. http://127.0.0.1{random_port})
|
// Returns address (e.g. http://127.0.0.1{random_port})
|
||||||
format!("http://{}:{}", host, port)
|
format!("http://{host}:{port}")
|
||||||
}
|
}
|
||||||
let listening_url = spawn_app("127.0.0.1").await;
|
let listening_url = spawn_app("127.0.0.1").await;
|
||||||
|
|
||||||
let mut event_stream = reqwest::Client::new()
|
let mut event_stream = reqwest::Client::new()
|
||||||
.get(format!("{}/sse", listening_url))
|
.get(format!("{listening_url}/sse"))
|
||||||
.header("User-Agent", "integration_test")
|
.header("User-Agent", "integration_test")
|
||||||
.send()
|
.send()
|
||||||
.await
|
.await
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ mod unix {
|
|||||||
let (mut sender, conn) = hyper::client::conn::http1::handshake(stream).await.unwrap();
|
let (mut sender, conn) = hyper::client::conn::http1::handshake(stream).await.unwrap();
|
||||||
tokio::task::spawn(async move {
|
tokio::task::spawn(async move {
|
||||||
if let Err(err) = conn.await {
|
if let Err(err) = conn.await {
|
||||||
println!("Connection failed: {:?}", err);
|
println!("Connection failed: {err:?}");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -79,7 +79,7 @@ mod unix {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async fn handler(ConnectInfo(info): ConnectInfo<UdsConnectInfo>) -> &'static str {
|
async fn handler(ConnectInfo(info): ConnectInfo<UdsConnectInfo>) -> &'static str {
|
||||||
println!("new connection from `{:?}`", info);
|
println!("new connection from `{info:?}`");
|
||||||
|
|
||||||
"Hello, World!"
|
"Hello, World!"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -129,13 +129,13 @@ fn process_message(msg: Message, who: usize) -> ControlFlow<(), ()> {
|
|||||||
println!(">>> {who} got str: {t:?}");
|
println!(">>> {who} got str: {t:?}");
|
||||||
}
|
}
|
||||||
Message::Binary(d) => {
|
Message::Binary(d) => {
|
||||||
println!(">>> {} got {} bytes: {:?}", who, d.len(), d);
|
println!(">>> {who} got {} bytes: {d:?}", d.len());
|
||||||
}
|
}
|
||||||
Message::Close(c) => {
|
Message::Close(c) => {
|
||||||
if let Some(cf) = c {
|
if let Some(cf) = c {
|
||||||
println!(
|
println!(
|
||||||
">>> {} got close with code {} and reason `{}`",
|
">>> {who} got close with code {} and reason `{}`",
|
||||||
who, cf.code, cf.reason
|
cf.code, cf.reason
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
println!(">>> {who} somehow got close message without CloseFrame");
|
println!(">>> {who} somehow got close message without CloseFrame");
|
||||||
|
|||||||
@@ -220,13 +220,13 @@ fn process_message(msg: Message, who: SocketAddr) -> ControlFlow<(), ()> {
|
|||||||
println!(">>> {who} sent str: {t:?}");
|
println!(">>> {who} sent str: {t:?}");
|
||||||
}
|
}
|
||||||
Message::Binary(d) => {
|
Message::Binary(d) => {
|
||||||
println!(">>> {} sent {} bytes: {:?}", who, d.len(), d);
|
println!(">>> {who} sent {} bytes: {d:?}", d.len());
|
||||||
}
|
}
|
||||||
Message::Close(c) => {
|
Message::Close(c) => {
|
||||||
if let Some(cf) = c {
|
if let Some(cf) = c {
|
||||||
println!(
|
println!(
|
||||||
">>> {} sent close with code {} and reason `{}`",
|
">>> {who} sent close with code {} and reason `{}`",
|
||||||
who, cf.code, cf.reason
|
cf.code, cf.reason
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
println!(">>> {who} somehow sent close message without CloseFrame");
|
println!(">>> {who} somehow sent close message without CloseFrame");
|
||||||
|
|||||||
Reference in New Issue
Block a user