Skip to content

Commit

Permalink
chore(lint): fix errors
Browse files Browse the repository at this point in the history
Updated clippy locally and fixed errors and warnings
  • Loading branch information
believer committed May 2, 2024
1 parent 333ee5c commit 0ddd944
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 20 deletions.
20 changes: 11 additions & 9 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ extern crate confy;

use crate::utils::pkg_json;
use serde::{Deserialize, Serialize};
use std::fs;
use std::{fmt::Display, fs};

#[derive(clap::ValueEnum, Clone, Copy, Debug, Serialize, Deserialize, PartialEq)]
pub enum NodeInstaller {
Expand All @@ -12,14 +12,16 @@ pub enum NodeInstaller {
Bun,
}

impl ToString for NodeInstaller {
fn to_string(&self) -> String {
match self {
NodeInstaller::Npm => "npm".to_string(),
NodeInstaller::Yarn => "yarn".to_string(),
NodeInstaller::Pnpm => "pnpm".to_string(),
NodeInstaller::Bun => "bun".to_string(),
}
impl Display for NodeInstaller {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let lib = match self {
NodeInstaller::Npm => "npm",
NodeInstaller::Yarn => "yarn",
NodeInstaller::Pnpm => "pnpm",
NodeInstaller::Bun => "bun",
};

write!(f, "{}", lib)
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/utils/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ pub fn remove_scripts(scripts: Vec<&str>) -> Result<()> {
let mut pkg = pkg_json::Package::new()?;

scripts.iter().for_each(|name| {
pkg.scripts.remove(&name.to_string());
pkg.scripts.remove(*name);
});

let json = serde_json::to_string_pretty(&pkg)?;
Expand Down
18 changes: 8 additions & 10 deletions src/utils/project.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use colored::*;
use dialoguer::{theme::ColorfulTheme, Select};
use include_dir_macro::include_dir;
use std::fmt::Display;
use std::fs;
use std::{collections, path};

Expand All @@ -11,14 +12,15 @@ pub enum ProjectType {
Rust,
}

impl ToString for ProjectType {
fn to_string(&self) -> String {
match self {
impl Display for ProjectType {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let language = match self {
ProjectType::JavaScript => "JavaScript",
ProjectType::ReScript => "ReScript",
ProjectType::Rust => "Rust",
}
.to_string()
};

write!(f, "{}", language)
}
}

Expand Down Expand Up @@ -94,11 +96,7 @@ impl Project {
}

pub fn log(&self) {
println!(
"{} Found {} project",
"✔".green(),
self.project_type.to_string()
);
println!("{} Found {} project", "✔".green(), self.project_type);
}

pub fn new(project_type: Option<ProjectType>) -> Project {
Expand Down

0 comments on commit 0ddd944

Please sign in to comment.