refactor(examples): remove lifetime workaround in send_file example

The lifetime workaround is no longer required due to changes in
rustc. This removes the line and comment from the example.
This commit is contained in:
memoryruins
2019-09-11 10:54:29 -04:00
committed by Sean McArthur
parent 144893b409
commit 1341cde365

View File

@@ -61,13 +61,11 @@ fn internal_server_error() -> Response<Body> {
.unwrap() .unwrap()
} }
async fn simple_file_send(f: &str) -> Result<Response<Body>> { async fn simple_file_send(filename: &str) -> Result<Response<Body>> {
// Serve a file by asynchronously reading it entirely into memory. // Serve a file by asynchronously reading it entirely into memory.
// Uses tokio_fs to open file asynchronously, then tokio::io::AsyncReadExt // Uses tokio_fs to open file asynchronously, then tokio::io::AsyncReadExt
// to read into memory asynchronously. // to read into memory asynchronously.
let filename = f.to_string(); // we need to copy for lifetime issues
if let Ok(mut file) = File::open(filename).await { if let Ok(mut file) = File::open(filename).await {
let mut buf = Vec::new(); let mut buf = Vec::new();
if let Ok(_) = file.read_to_end(&mut buf).await { if let Ok(_) = file.read_to_end(&mut buf).await {