From 5d3d1fb20e86e6cc91d05017c802c02fd4c78dad Mon Sep 17 00:00:00 2001 From: fakeshadow <24548779@qq.com> Date: Sun, 17 Oct 2021 04:10:15 +0800 Subject: [PATCH] fix clippy warning --- actix-files/src/chunked.rs | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/actix-files/src/chunked.rs b/actix-files/src/chunked.rs index 4d80303d3..df396f6a5 100644 --- a/actix-files/src/chunked.rs +++ b/actix-files/src/chunked.rs @@ -92,25 +92,23 @@ fn chunked_read_file_callback( } #[cfg(feature = "io-uring")] -fn chunked_read_file_callback( +async fn chunked_read_file_callback( file: File, offset: u64, max_bytes: usize, -) -> impl Future> { - async move { - let buf = Vec::with_capacity(max_bytes); +) -> io::Result<(File, Bytes)> { + let buf = Vec::with_capacity(max_bytes); - let (res, mut buf) = file.read_at(buf, offset).await; - let n_bytes = res?; + let (res, mut buf) = file.read_at(buf, offset).await; + let n_bytes = res?; - if n_bytes == 0 { - return Err(io::ErrorKind::UnexpectedEof.into()); - } - - let _ = buf.split_off(n_bytes); - - Ok((file, Bytes::from(buf))) + if n_bytes == 0 { + return Err(io::ErrorKind::UnexpectedEof.into()); } + + let _ = buf.split_off(n_bytes); + + Ok((file, Bytes::from(buf))) } #[cfg(feature = "io-uring")]