🚨 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::{ use std::{
collections::HashMap, collections::HashMap,
convert::TryInto,
path::{Path, PathBuf}, path::{Path, PathBuf},
}; };
@ -16,7 +15,6 @@ use tokio::{
read_dir, read_dir,
ReadDir, ReadDir,
}, },
io::AsyncReadExt,
}; };
#[cfg (test)] #[cfg (test)]
@ -133,7 +131,7 @@ fn serve_dir (
} }
async fn serve_file ( async fn serve_file (
mut file: tokio::fs::File, file: tokio::fs::File,
uri: &http::Uri, uri: &http::Uri,
send_body: bool, send_body: bool,
headers: &HashMap <String, Vec <u8>> headers: &HashMap <String, Vec <u8>>
@ -175,7 +173,11 @@ async fn serve_file (
return Ok (Response::MarkdownErr (MarkdownErrWrapper::new (markdown::Error::TooBig))); return Ok (Response::MarkdownErr (MarkdownErrWrapper::new (markdown::Error::TooBig)));
} }
else { 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 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?; let bytes_read = file.read (&mut buffer).await?;
buffer.truncate (bytes_read); buffer.truncate (bytes_read);

View File

@ -294,7 +294,10 @@ pub async fn serve_all (
} }
#[cfg (not (feature = "markdown"))] #[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), MarkdownPreview (s) => html::serve (s),
}) })

View File

@ -95,10 +95,10 @@ async fn handle_one_req (
tokio::spawn (async move { tokio::spawn (async move {
while let Some (chunk) = body.recv ().await { 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?; tx.send (chunk).await?;
if let Some (len) = len { if let Some (_len) = len {
// debug! ("Throttling {} byte chunk", len); // debug! ("Throttling {} byte chunk", len);
} }