From b88d41f3db1cfcdc7a2faffcb27227a4bf6861d5 Mon Sep 17 00:00:00 2001 From: Roey Darwish Dror Date: Mon, 31 Dec 2018 22:23:04 +0200 Subject: [PATCH] Reduced multiple calls to context --- src/self_update.rs | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/self_update.rs b/src/self_update.rs index 8b461246..3f3f63c3 100644 --- a/src/self_update.rs +++ b/src/self_update.rs @@ -17,18 +17,18 @@ pub fn self_update() -> Result<(), Error> { let target = self_update_crate::get_target().context(ErrorKind::SelfUpdate)?; let result = Update::configure() - .context(ErrorKind::SelfUpdate)? - .repo_owner("r-darwish") - .repo_name("topgrade") - .target(&target) - .bin_name(if cfg!(windows) { "topgrade.exe" } else { "topgrade" }) - .show_output(false) - .show_download_progress(true) - .current_version(self_update_crate::cargo_crate_version!()) - .no_confirm(true) - .build() - .context(ErrorKind::SelfUpdate)? - .update2() + .and_then(|mut u| { + u.repo_owner("r-darwish") + .repo_name("topgrade") + .target(&target) + .bin_name(if cfg!(windows) { "topgrade.exe" } else { "topgrade" }) + .show_output(false) + .show_download_progress(true) + .current_version(self_update_crate::cargo_crate_version!()) + .no_confirm(true) + .build() + }) + .and_then(|u| u.update2()) .context(ErrorKind::SelfUpdate)?; if let GitHubUpdateStatus::Updated(release) = &result {