diff --git a/src/helpers.rs b/src/helpers.rs index f60df2d8..8ee87f9a 100644 --- a/src/helpers.rs +++ b/src/helpers.rs @@ -65,7 +65,7 @@ pub async fn download>(url: &str, path: P) -> Result<(), Binstall debug!("Downloading to file: '{}'", path.display()); let mut bytes_stream = resp.bytes_stream(); - let mut writer = AsyncFileWriter::new(path)?; + let mut writer = AsyncFileWriter::new(path); while let Some(res) = bytes_stream.next().await { writer.write(res?).await?; diff --git a/src/helpers/async_file_writer.rs b/src/helpers/async_file_writer.rs index 6405c777..12f69133 100644 --- a/src/helpers/async_file_writer.rs +++ b/src/helpers/async_file_writer.rs @@ -25,7 +25,7 @@ struct AsyncFileWriterInner { } impl AsyncFileWriterInner { - fn new(path: &Path) -> io::Result { + fn new(path: &Path) -> Self { let path = path.to_owned(); let (tx, rx) = mpsc::channel::(100); @@ -60,7 +60,7 @@ impl AsyncFileWriterInner { Ok(()) })); - Ok(Self { handle, tx }) + Self { handle, tx } } /// Upon error, this writer shall not be reused. @@ -110,8 +110,9 @@ impl AsyncFileWriterInner { pub struct AsyncFileWriter(ScopeGuard); impl AsyncFileWriter { - pub fn new(path: &Path) -> io::Result { - AsyncFileWriterInner::new(path).map(|inner| Self(guard(inner, AsyncFileWriterInner::abort))) + pub fn new(path: &Path) -> Self { + let inner = AsyncFileWriterInner::new(path); + Self(guard(inner, AsyncFileWriterInner::abort)) } /// Upon error, this writer shall not be reused.