🚨 refactor: cargo clippy

main
_ 2021-04-03 15:30:32 +00:00
parent 5a6d9314cc
commit 6e24983ad7
3 changed files with 11 additions and 6 deletions

View File

@ -5,7 +5,6 @@
use std::{
collections::HashMap,
convert::TryInto,
path::{Path, PathBuf},
};
@ -16,7 +15,6 @@ use tokio::{
read_dir,
ReadDir,
},
io::AsyncReadExt,
};
#[cfg (test)]
@ -133,7 +131,7 @@ fn serve_dir (
}
async fn serve_file (
mut file: tokio::fs::File,
file: tokio::fs::File,
uri: &http::Uri,
send_body: bool,
headers: &HashMap <String, Vec <u8>>
@ -175,7 +173,11 @@ async fn serve_file (
return Ok (Response::MarkdownErr (MarkdownErrWrapper::new (markdown::Error::TooBig)));
}
else {
use std::convert::TryInto;
use tokio::io::AsyncReadExt;
let mut buffer = vec! [0_u8; MAX_BUF_SIZE.try_into ().expect ("Couldn't fit u32 into usize")];
let mut file = file;
let bytes_read = file.read (&mut buffer).await?;
buffer.truncate (bytes_read);

View File

@ -294,7 +294,10 @@ pub async fn serve_all (
}
#[cfg (not (feature = "markdown"))]
serve_error (StatusCode::BadRequest, "Markdown feature is disabled")
{
let _e = e;
serve_error (StatusCode::BadRequest, "Markdown feature is disabled")
}
},
MarkdownPreview (s) => html::serve (s),
})

View File

@ -95,10 +95,10 @@ async fn handle_one_req (
tokio::spawn (async move {
while let Some (chunk) = body.recv ().await {
let len = chunk.as_ref ().map (|x| x.len ()).ok ();
let len = chunk.as_ref ().map (Vec::len).ok ();
tx.send (chunk).await?;
if let Some (len) = len {
if let Some (_len) = len {
// debug! ("Throttling {} byte chunk", len);
}