Skip to content

Commit d3991bd

Browse files
committed
fix clippy errors and warnings
1 parent 634e444 commit d3991bd

File tree

5 files changed

+18
-18
lines changed

5 files changed

+18
-18
lines changed

src/node_version.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,26 +19,26 @@ pub trait NodeVersion {
1919
fn version(&self) -> &Version;
2020
}
2121

22-
impl PartialEq<Self> for dyn NodeVersion {
22+
impl PartialEq for dyn NodeVersion {
2323
fn eq(&self, other: &Self) -> bool {
2424
self.version().eq(other.version())
2525
}
2626
}
2727

2828
impl Eq for dyn NodeVersion {}
2929

30-
impl PartialOrd<Self> for dyn NodeVersion {
31-
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
32-
Some(self.version().cmp(other.version()))
33-
}
34-
}
35-
3630
impl Ord for dyn NodeVersion {
3731
fn cmp(&self, other: &Self) -> Ordering {
3832
self.version().cmp(other.version())
3933
}
4034
}
4135

36+
impl PartialOrd for dyn NodeVersion {
37+
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
38+
Some(self.cmp(other))
39+
}
40+
}
41+
4242
pub fn parse_range(value: &str) -> Result<Range> {
4343
Range::parse(value).context(value.to_string())
4444
}
@@ -141,9 +141,9 @@ impl OnlineNodeVersion {
141141
}
142142
}
143143

144-
impl ToString for OnlineNodeVersion {
145-
fn to_string(&self) -> String {
146-
self.version.to_string()
144+
impl std::fmt::Display for OnlineNodeVersion {
145+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
146+
write!(f, "{}", self.version)
147147
}
148148
}
149149

@@ -268,9 +268,9 @@ impl InstalledNodeVersion {
268268
}
269269
}
270270

271-
impl ToString for InstalledNodeVersion {
272-
fn to_string(&self) -> String {
273-
self.version.to_string()
271+
impl std::fmt::Display for InstalledNodeVersion {
272+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
273+
write!(f, "{}", self.version)
274274
}
275275
}
276276

src/subcommand/install.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ impl Action<InstallCommand> for InstallCommand {
6767
if config.force
6868
|| (options.switch
6969
&& dialoguer::Confirm::new()
70-
.with_prompt(format!("Switch to {}?", version_to_install.to_string()))
70+
.with_prompt(format!("Switch to {}?", version_to_install))
7171
.default(true)
7272
.interact()?)
7373
{

src/subcommand/is_installed.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ impl Action<IsInstalledCommand> for IsInstalledCommand {
4848
if !options.quiet {
4949
println!(
5050
"✅ A version matching {version_filter} is installed ({})!",
51-
installed_version.to_string()
51+
installed_version
5252
);
5353
}
5454
return Ok(());

src/subcommand/list.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ impl<'p> VersionStatus<'p> {
4040

4141
fn to_version_string(&self) -> String {
4242
match self {
43-
VersionStatus::Outdated(version) => format!("-> {}", version.to_string()),
43+
VersionStatus::Outdated(version) => format!("-> {}", version),
4444
_ => "".to_string(),
4545
}
4646
}

src/subcommand/switch.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,12 @@ impl Action<SwitchCommand> for SwitchCommand {
4747
let version = version.unwrap();
4848

4949
if !InstalledNodeVersion::is_installed(config, version.version()) {
50-
anyhow::bail!("{} is not installed", version.to_string());
50+
anyhow::bail!("{} is not installed", version);
5151
}
5252

5353
let result = set_shims(config, version.version());
5454
if let Ok(()) = result {
55-
println!("Switched to {}", version.to_string());
55+
println!("Switched to {}", version);
5656
}
5757

5858
result

0 commit comments

Comments
 (0)