From d65e3539795f079b6cf3887266441cfc844fa02c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=BF=B7=E6=B8=A1?= Date: Fri, 15 Nov 2024 12:23:18 +0800 Subject: [PATCH] fix lint (#205) --- src/commands/list.rs | 5 +---- src/meta.rs | 2 ++ 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/commands/list.rs b/src/commands/list.rs index ce358d9..66b7d51 100644 --- a/src/commands/list.rs +++ b/src/commands/list.rs @@ -18,10 +18,7 @@ pub fn exec_remote() -> Result<()> { } fn print_versions(mut versions: Vec) { - let current_version = match current_version() { - Some(v) => v, - _ => String::from(""), - }; + let current_version = current_version().unwrap_or_default(); versions.sort_by(|a, b| sort_semver_version(b, a).reverse()); diff --git a/src/meta.rs b/src/meta.rs index ac5c690..003e6c4 100644 --- a/src/meta.rs +++ b/src/meta.rs @@ -13,6 +13,7 @@ pub const DEFAULT_ALIAS: phf::Map<&'static str, &'static str> = phf::phf_map! { }; pub trait ToVersionReq { + #[allow(dead_code)] fn to_version_req(&self) -> VersionReq; fn try_to_version_req(&self) -> anyhow::Result; } @@ -334,6 +335,7 @@ mod tests { assert_eq!(parsed.versions.len(), 2); assert_eq!(parsed.alias[0].name, "latest"); assert_eq!(parsed.alias[0].required, "*"); + assert_eq!(parsed.alias[0].to_version_req(), VersionReq::parse("*").unwrap()); assert!(parsed.alias[0].try_to_version_req().is_ok()); assert_eq!(parsed.alias[1].name, "stable"); assert_eq!(parsed.alias[1].required, "^1.0.0");