Use io::Error::downcast in 1.79 (#1754)

* Bump msrv of binstalk-downloader, binstalk and cargo-binstall to 1.79

* Update From<io::Error> for DownloadError

to use io::Error::downcast

* Update From<io::Error> for BinstallError

* fix dmt
This commit is contained in:
Jiahao XU 2024-06-14 18:00:53 +10:00 committed by GitHub
parent dfa230f039
commit 34cca9f415
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 7 additions and 31 deletions

View file

@ -4,7 +4,7 @@ description = "Binary installation for rust projects"
repository = "https://github.com/cargo-bins/cargo-binstall" repository = "https://github.com/cargo-bins/cargo-binstall"
documentation = "https://docs.rs/cargo-binstall" documentation = "https://docs.rs/cargo-binstall"
version = "1.6.9" version = "1.6.9"
rust-version = "1.70.0" rust-version = "1.79.0"
authors = ["ryan <ryan@kurte.nz>"] authors = ["ryan <ryan@kurte.nz>"]
edition = "2021" edition = "2021"
license = "GPL-3.0-only" license = "GPL-3.0-only"

View file

@ -4,7 +4,7 @@ description = "The binstall toolkit for downloading and extracting file"
repository = "https://github.com/cargo-bins/cargo-binstall" repository = "https://github.com/cargo-bins/cargo-binstall"
documentation = "https://docs.rs/binstalk-downloader" documentation = "https://docs.rs/binstalk-downloader"
version = "0.11.2" version = "0.11.2"
rust-version = "1.70.0" rust-version = "1.79.0"
authors = ["ryan <ryan@kurte.nz>"] authors = ["ryan <ryan@kurte.nz>"]
edition = "2021" edition = "2021"
license = "Apache-2.0 OR MIT" license = "Apache-2.0 OR MIT"

View file

@ -44,20 +44,8 @@ pub enum DownloadError {
impl From<io::Error> for DownloadError { impl From<io::Error> for DownloadError {
fn from(err: io::Error) -> Self { fn from(err: io::Error) -> Self {
if err.get_ref().is_some() { err.downcast::<DownloadError>()
let kind = err.kind(); .unwrap_or_else(DownloadError::Io)
let inner = err
.into_inner()
.expect("err.get_ref() returns Some, so err.into_inner() should also return Some");
inner
.downcast()
.map(|b| *b)
.unwrap_or_else(|err| DownloadError::Io(io::Error::new(kind, err)))
} else {
DownloadError::Io(err)
}
} }
} }

View file

@ -4,7 +4,7 @@ description = "The binstall toolkit (library interface)"
repository = "https://github.com/cargo-bins/cargo-binstall" repository = "https://github.com/cargo-bins/cargo-binstall"
documentation = "https://docs.rs/binstalk" documentation = "https://docs.rs/binstalk"
version = "0.24.0" version = "0.24.0"
rust-version = "1.65.0" rust-version = "1.79.0"
authors = ["ryan <ryan@kurte.nz>"] authors = ["ryan <ryan@kurte.nz>"]
edition = "2021" edition = "2021"
license = "GPL-3.0-only" license = "GPL-3.0-only"

View file

@ -530,20 +530,8 @@ impl Termination for BinstallError {
impl From<io::Error> for BinstallError { impl From<io::Error> for BinstallError {
fn from(err: io::Error) -> Self { fn from(err: io::Error) -> Self {
if err.get_ref().is_some() { err.downcast::<BinstallError>()
let kind = err.kind(); .unwrap_or_else(BinstallError::Io)
let inner = err
.into_inner()
.expect("err.get_ref() returns Some, so err.into_inner() should also return Some");
inner
.downcast()
.map(|b| *b)
.unwrap_or_else(|err| BinstallError::Io(io::Error::new(kind, err)))
} else {
BinstallError::Io(err)
}
} }
} }