From 2d651b75e528898064136da64d4e171dbb66b96e Mon Sep 17 00:00:00 2001 From: Michal Date: Sat, 23 Jul 2022 18:15:12 +0100 Subject: [PATCH] Pedantic clippy moment --- Cargo.toml | 1 + src/internal/strings.rs | 15 ++++++--------- src/main.rs | 2 +- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 3b9abbc..9923a3f 100755 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,6 +4,7 @@ version = "2.0.0" authors = [ "michal " ] edition = "2021" description = "Packaging tool for pacman repositories" +repository = "https://github.com/crystal-linux/malachite" license-file = "LICENSE" keywords = [ "pacman", "repository", "packaging" ] categories = [ "filesystem", "development-tools" ] diff --git a/src/internal/strings.rs b/src/internal/strings.rs index 2d5feda..b5b314b 100755 --- a/src/internal/strings.rs +++ b/src/internal/strings.rs @@ -10,31 +10,29 @@ const ERR_SYMBOL: &str = "❌"; #[macro_export] macro_rules! info { ($($arg:tt)+) => { - $crate::internal::strings::info_fn(format!($($arg)+)); + $crate::internal::strings::info_fn(&format!($($arg)+)); } } #[macro_export] macro_rules! log { ($verbose:expr, $($arg:tt)+) => { - $crate::internal::strings::log_fn(format!("{}:{} {}", file!(), line!(), format!($($arg)+)), $verbose); + $crate::internal::strings::log_fn(&format!("{}:{} {}", file!(), line!(), format!($($arg)+)), $verbose); } } #[macro_export] macro_rules! crash { ($exit_code:expr, $($arg:tt)+) => { - $crate::internal::strings::crash_fn(format!($($arg)+), $exit_code) + $crate::internal::strings::crash_fn(&format!($($arg)+), $exit_code) } } -pub fn info_fn(msg: S) { - let msg = msg.to_string(); +pub fn info_fn(msg: &str) { println!("{} {}", LOGO_SYMBOL.black(), msg.bold()); } -pub fn log_fn(msg: S, verbose: bool) { - let msg = msg.to_string(); +pub fn log_fn(msg: &str, verbose: bool) { if verbose { eprintln!( "{} {}", @@ -47,8 +45,7 @@ pub fn log_fn(msg: S, verbose: bool) { } } -pub fn crash_fn(msg: S, exit_code: AppExitCode) { - let msg = msg.to_string(); +pub fn crash_fn(msg: &str, exit_code: AppExitCode) { println!("{} {}", ERR_SYMBOL.red(), msg.bold()); exit(exit_code as i32); } diff --git a/src/main.rs b/src/main.rs index 5a1fdc7..558b1ae 100755 --- a/src/main.rs +++ b/src/main.rs @@ -1,4 +1,4 @@ -#![warn(clippy::all, clippy::pedantic, clippy::nursery)] +#![warn(clippy::all, clippy::pedantic, clippy::nursery, clippy::cargo)] use clap::Parser; use std::env;