From 621f599e3262029a626d716a20ff8ce7c907d035 Mon Sep 17 00:00:00 2001 From: trivernis Date: Sun, 22 Jan 2023 12:45:01 +0100 Subject: [PATCH] Fix clippy linting errors --- src/consts.rs | 2 +- src/error.rs | 2 +- src/main.rs | 16 ++++++++-------- src/mapper/mapped_dir.rs | 2 +- src/repository/mod.rs | 8 ++++---- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/consts.rs b/src/consts.rs index 1331e37..9aa99af 100644 --- a/src/consts.rs +++ b/src/consts.rs @@ -62,7 +62,7 @@ map_os!( ); #[cfg(not(target_os = "windows"))] -pub const ARCHIVE_TYPE: &'static str = "tar.gz"; +pub const ARCHIVE_TYPE: &str = "tar.gz"; #[cfg(target_os = "windows")] pub const ARCHIVE_TYPE: &'static str = "zip"; diff --git a/src/error.rs b/src/error.rs index aaf71ad..19fa1da 100644 --- a/src/error.rs +++ b/src/error.rs @@ -106,7 +106,7 @@ impl ParseTomlError { .map(|p| SourceSpan::new(p.into(), 0.into())); Self { src: NamedSource::new(file_name, src), - pos: abs_pos.into(), + pos: abs_pos, caused_by, } } diff --git a/src/main.rs b/src/main.rs index 00de511..313ab1d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -29,7 +29,10 @@ async fn main() -> Result<()> { let args: Args = Args::parse(); match args.commmand { - args::Command::Version => Ok(print_version()), + args::Command::Version => { + print_version(); + Ok(()) + }, args::Command::Install(v) => install_version(v.version).await, args::Command::Default(v) => set_default_version(v.version).await, args::Command::Exec(args) => { @@ -56,18 +59,15 @@ pub async fn install_version(version: NodeVersion) -> Result<()> { } let repo = get_repository().await?; - if repo.is_installed(&version)? { - if !Confirm::new() + if repo.is_installed(&version)? && !Confirm::new() .with_prompt(format!( "The version {} is already installed. Reinstall?", version.to_string().bold() )) .default(false) .interact() - .unwrap() - { - return Ok(()); - } + .unwrap() { + return Ok(()); } repo.install_version(&version).await?; println!("Installed {}", version.to_string().bold()); @@ -102,7 +102,7 @@ pub async fn exec(command: String, args: Vec) -> Result { let active_version = mapper.active_version(); if !mapper.repository().is_installed(active_version)? { - mapper.repository().install_version(&active_version).await?; + mapper.repository().install_version(active_version).await?; } let exit_status = mapper.exec(command, args).await?; diff --git a/src/mapper/mapped_dir.rs b/src/mapper/mapped_dir.rs index d8433bf..a283d85 100644 --- a/src/mapper/mapped_dir.rs +++ b/src/mapper/mapped_dir.rs @@ -56,7 +56,7 @@ impl NodeApp { } pub async fn map_node_bin(node_path: NodePath) -> Result<()> { - let mapped_app_names = get_applications(&*BIN_DIR) + let mapped_app_names = get_applications(&BIN_DIR) .await? .iter() .map(NodeApp::name) diff --git a/src/repository/mod.rs b/src/repository/mod.rs index 8d9c59c..909aff2 100644 --- a/src/repository/mod.rs +++ b/src/repository/mod.rs @@ -120,7 +120,7 @@ impl Repository { /// Returns the path for the given node version pub fn get_version_path(&self, version: &NodeVersion) -> Result> { - let info = self.lookup_version(&version)?; + let info = self.lookup_version(version)?; let path = build_version_path(&info.version); Ok(if path.exists() { @@ -158,11 +158,11 @@ impl Repository { NodeVersion::LatestLts => self.versions.latest_lts(), NodeVersion::Lts(lts) => self .versions - .get_lts(<s) + .get_lts(lts) .ok_or_else(|| VersionError::unknown_version(lts.to_owned()))?, NodeVersion::Req(req) => self .versions - .get_fulfilling(&req) + .get_fulfilling(req) .ok_or_else(|| VersionError::unfulfillable_version(req.to_owned()))?, }; @@ -176,7 +176,7 @@ impl Repository { /// Installs a specified node version pub async fn install_version(&self, version_req: &NodeVersion) -> Result<()> { - let info = self.lookup_version(&version_req)?; + let info = self.lookup_version(version_req)?; let archive_path = self.download_version(&info.version).await?; self.extract_archive(info, &archive_path)?;