Pedantic clippy moment

main
Michal 2 years ago
parent 21d47dd26a
commit e6935dd655

@ -4,6 +4,7 @@ version = "2.0.0"
authors = [ "michal <michal@tar.black>" ] authors = [ "michal <michal@tar.black>" ]
edition = "2021" edition = "2021"
description = "Packaging tool for pacman repositories" description = "Packaging tool for pacman repositories"
repository = "https://github.com/crystal-linux/malachite"
license-file = "LICENSE" license-file = "LICENSE"
keywords = [ "pacman", "repository", "packaging" ] keywords = [ "pacman", "repository", "packaging" ]
categories = [ "filesystem", "development-tools" ] categories = [ "filesystem", "development-tools" ]

@ -10,31 +10,29 @@ const ERR_SYMBOL: &str = "❌";
#[macro_export] #[macro_export]
macro_rules! info { macro_rules! info {
($($arg:tt)+) => { ($($arg:tt)+) => {
$crate::internal::strings::info_fn(format!($($arg)+)); $crate::internal::strings::info_fn(&format!($($arg)+));
} }
} }
#[macro_export] #[macro_export]
macro_rules! log { macro_rules! log {
($verbose:expr, $($arg:tt)+) => { ($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_export]
macro_rules! crash { macro_rules! crash {
($exit_code:expr, $($arg:tt)+) => { ($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<S: ToString>(msg: S) { pub fn info_fn(msg: &str) {
let msg = msg.to_string();
println!("{} {}", LOGO_SYMBOL.black(), msg.bold()); println!("{} {}", LOGO_SYMBOL.black(), msg.bold());
} }
pub fn log_fn<S: ToString>(msg: S, verbose: bool) { pub fn log_fn(msg: &str, verbose: bool) {
let msg = msg.to_string();
if verbose { if verbose {
eprintln!( eprintln!(
"{} {}", "{} {}",
@ -47,8 +45,7 @@ pub fn log_fn<S: ToString>(msg: S, verbose: bool) {
} }
} }
pub fn crash_fn<S: ToString>(msg: S, exit_code: AppExitCode) { pub fn crash_fn(msg: &str, exit_code: AppExitCode) {
let msg = msg.to_string();
println!("{} {}", ERR_SYMBOL.red(), msg.bold()); println!("{} {}", ERR_SYMBOL.red(), msg.bold());
exit(exit_code as i32); exit(exit_code as i32);
} }

@ -1,4 +1,4 @@
#![warn(clippy::all, clippy::pedantic, clippy::nursery)] #![warn(clippy::all, clippy::pedantic, clippy::nursery, clippy::cargo)]
use clap::Parser; use clap::Parser;
use std::env; use std::env;

Loading…
Cancel
Save