Skip to content

Commit d312abb

Browse files
committed
remove Result:: prefixes
1 parent e12f4fd commit d312abb

File tree

6 files changed

+17
-21
lines changed

6 files changed

+17
-21
lines changed

src/archives.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ pub fn extract_archive(bytes: Response, path: &Path) -> Result<()> {
5555
.unwrap_or_else(|| path.to_str().unwrap())
5656
);
5757

58-
Result::Ok(())
58+
Ok(())
5959
}
6060

6161
#[cfg(unix)]
@@ -97,7 +97,7 @@ pub fn extract_archive(bytes: Response, path: &Path) -> Result<()> {
9797
if !errors.is_empty() {
9898
remove_dir_all(version_dir_path).expect("Couldn't clean up version.");
9999

100-
return Result::Err(anyhow::anyhow!(
100+
return Err(anyhow::anyhow!(
101101
"Failed to extract all files:\n{:?}",
102102
errors
103103
.into_iter()
@@ -109,5 +109,5 @@ pub fn extract_archive(bytes: Response, path: &Path) -> Result<()> {
109109

110110
println!("Extracted to {:?}", version_dir_path);
111111

112-
Result::Ok(())
112+
Ok(())
113113
}

src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,6 @@ fn main() -> Result<()> {
119119
Subcommands::Use(ref options) => SwitchCommand::run(&config, options),
120120
Subcommands::ParseVersion(ref options) => ParseVersionCommand::run(&config, options),
121121
#[allow(unreachable_patterns)]
122-
_ => Result::Ok(()),
122+
_ => Ok(()),
123123
}
124124
}

src/subcommand/install.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ impl Action<InstallCommand> for InstallCommand {
5454
version_to_install.version()
5555
);
5656

57-
return Result::Ok(());
57+
return Ok(());
5858
}
5959

6060
download_and_extract_to(
@@ -79,7 +79,7 @@ impl Action<InstallCommand> for InstallCommand {
7979
)?;
8080
}
8181

82-
Result::Ok(())
82+
Ok(())
8383
}
8484
}
8585

src/subcommand/switch.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ impl Action<SwitchCommand> for SwitchCommand {
5656
}
5757

5858
let result = set_shims(config, version.version());
59-
if let Result::Ok(()) = result {
59+
if let Ok(()) = result {
6060
println!("Switched to {}", version.to_string());
6161
}
6262

@@ -69,16 +69,12 @@ fn set_shims(config: &Config, version: &Version) -> Result<()> {
6969
let shims_dir = config.get_shims_dir();
7070

7171
if !InstalledNodeVersion::is_installed(config, version) {
72-
anyhow::bail!("{} is not installed", version);
72+
anyhow::bail!("{version} is not installed");
7373
}
7474

7575
if read_link(&shims_dir).is_ok() {
76-
if let Result::Err(err) = remove_dir(&shims_dir) {
77-
anyhow::bail!(
78-
"Could not remove old symlink at {:?}: {}",
79-
shims_dir,
80-
err.to_string()
81-
);
76+
if let Err(err) = remove_dir(&shims_dir) {
77+
anyhow::bail!("Could not remove old symlink at {shims_dir:?}: {err}",);
8278
}
8379
}
8480

src/subcommand/uninstall.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ impl Action<UninstallCommand> for UninstallCommand {
3838
.with_prompt("Are you sure you want to uninstall it?")
3939
.interact()?)
4040
{
41-
return Result::Ok(());
41+
return Ok(());
4242
}
4343

4444
InstalledNodeVersion::deselect(config)?;

tests/utils.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ pub fn setup_integration_test() -> Result<(TempDir, Command)> {
3232
let mut cmd = Command::cargo_bin("nvm").expect("Could not create Command");
3333
cmd.args(&["--dir", &temp_dir.to_string_lossy()]);
3434

35-
Result::Ok((temp_dir, cmd))
35+
Ok((temp_dir, cmd))
3636
}
3737

3838
pub fn install_mock_version(path: &Path, version_str: &str) -> Result<()> {
@@ -54,7 +54,7 @@ pub fn install_mock_version(path: &Path, version_str: &str) -> Result<()> {
5454
.unwrap_or_else(|err| panic!("Failed to write to {:#?}: {}", &file_path, err))
5555
}
5656

57-
Result::Ok(())
57+
Ok(())
5858
}
5959

6060
#[allow(dead_code)]
@@ -112,7 +112,7 @@ stderr output:
112112
)
113113
}
114114

115-
Result::Ok(())
115+
Ok(())
116116
}
117117

118118
#[allow(dead_code)]
@@ -141,19 +141,19 @@ pub fn assert_version_installed(
141141
}
142142
}
143143

144-
Result::Ok(())
144+
Ok(())
145145
}
146146

147147
#[allow(dead_code)]
148148
pub fn get_selected_version(temp_dir: &TempDir) -> Option<String> {
149149
let symlink_path = temp_dir.child("shims");
150150

151151
match fs::read_link(&symlink_path) {
152-
Result::Ok(shims_dir) => {
152+
Ok(shims_dir) => {
153153
let file_path = shims_dir.join(required_files()[0]);
154154

155155
Some(fs::read_to_string(&file_path).unwrap())
156156
},
157-
Result::Err(_) => None,
157+
Err(_) => None,
158158
}
159159
}

0 commit comments

Comments
 (0)