clippy clean

This commit is contained in:
Sunli
2025-07-28 10:59:49 +08:00
parent afb3c8e4c1
commit 3d611d5fbb
4 changed files with 9 additions and 9 deletions

View File

@@ -21,7 +21,7 @@ use tokio::{spawn, time::sleep};
#[handler]
fn hello(Path(name): Path<String>) -> String {
format!("hello: {}", name)
format!("hello: {name}")
}
#[tokio::main]
@@ -55,7 +55,7 @@ async fn main() -> Result<(), std::io::Error> {
{
Ok(result) => result.rustls_key,
Err(err) => {
eprintln!("failed to issue certificate: {}", err);
eprintln!("failed to issue certificate: {err}");
sleep(Duration::from_secs(60 * 5)).await;
continue;
}

View File

@@ -104,7 +104,7 @@ mod tests {
for case in invalid_cases {
let result = Duration::parse_from_json(Some(Value::String(case.to_string())));
dbg!(&result);
assert!(result.is_err(), "Should have failed for: {}", case);
assert!(result.is_err(), "Should have failed for: {case}");
}
}

View File

@@ -14,11 +14,11 @@ pub fn build_poem_req(req: HttpRequest) -> Result<poem::Request> {
let local_addr = if let Some(client_ip) = headers.get("cf-connecting-ip") {
let client_ip = client_ip
.to_str()
.map_err(|e| worker::Error::RustError(format!("{}", e)))?;
.map_err(|e| worker::Error::RustError(format!("{e}")))?;
let ip_addr = client_ip
.parse::<IpAddr>()
.map_err(|e| worker::Error::RustError(format!("{}", e)))?;
.map_err(|e| worker::Error::RustError(format!("{e}")))?;
let addr = SocketAddr::new(ip_addr, 0);

View File

@@ -92,17 +92,17 @@ impl<E: RustEmbed + Send + Sync> Endpoint for EmbeddedFilesEndpoint<E> {
if path.is_empty() && !original_end_with_slash {
Ok(Response::builder()
.status(StatusCode::FOUND)
.header(LOCATION, format!("{}/", original_path))
.header(LOCATION, format!("{original_path}/"))
.finish())
} else if original_end_with_slash {
let path = format!("{}index.html", path);
let path = format!("{path}index.html");
EmbeddedFileEndpoint::<E>::new(&path).call(req).await
} else if E::get(path).is_some() {
EmbeddedFileEndpoint::<E>::new(path).call(req).await
} else if E::get(&format!("{}/index.html", path)).is_some() {
} else if E::get(&format!("{path}/index.html")).is_some() {
Ok(Response::builder()
.status(StatusCode::FOUND)
.header(LOCATION, format!("{}/", original_path))
.header(LOCATION, format!("{original_path}/"))
.finish())
} else {
EmbeddedFileEndpoint::<E>::new(path).call(req).await