From 3a26d70a4096b416024c66f554ef443a2e5b22c4 Mon Sep 17 00:00:00 2001 From: xfeusw Date: Mon, 19 Jan 2026 16:00:46 +0500 Subject: [PATCH] refactor: reduced where usages --- src/error.rs | 5 +---- src/manager.rs | 19 ++++--------------- src/schemes/template/apply.rs | 15 +++------------ 3 files changed, 8 insertions(+), 31 deletions(-) diff --git a/src/error.rs b/src/error.rs index d134062..5c6d661 100644 --- a/src/error.rs +++ b/src/error.rs @@ -72,10 +72,7 @@ pub enum BleurError { Unknown, } -pub fn beautiful_exit(message: T) -> ! -where - T: AsRef, -{ +pub fn beautiful_exit>(message: T) -> ! { eprintln!("{} {}", "error:".red(), message.as_ref()); std::process::exit(1) diff --git a/src/manager.rs b/src/manager.rs index b6a27de..9da6d16 100644 --- a/src/manager.rs +++ b/src/manager.rs @@ -37,10 +37,7 @@ impl ManageBuilder { }) } - pub fn source(self, url: T) -> Result - where - T: AsRef, - { + pub fn source>(self, url: T) -> Result { Ok(Self { temporary: self.temporary, method: self.method, @@ -51,10 +48,7 @@ impl ManageBuilder { }) } - pub fn fetch_method(self, method: T) -> Result - where - T: Methodical, - { + pub fn fetch_method(self, method: T) -> Result { if self.temporary.is_none() || self.remote.is_none() { return Err(Error::InsufficientArgumentsToDecide); } @@ -153,17 +147,12 @@ impl Manager { /// For HashMap to implement string search pub trait Glubtastic { - fn globs(&self, text: T) -> Vec - where - T: AsRef; + fn globs>(&self, text: T) -> Vec; } impl Glubtastic for HashMap { /// Catch all @variable@ references within a string - fn globs(&self, text: T) -> Vec - where - T: AsRef, - { + fn globs>(&self, text: T) -> Vec { REGEX .captures_iter(text.as_ref()) .map(|caps| { diff --git a/src/schemes/template/apply.rs b/src/schemes/template/apply.rs index e426b52..b57f2f2 100644 --- a/src/schemes/template/apply.rs +++ b/src/schemes/template/apply.rs @@ -9,10 +9,7 @@ enum Instructions { Unknown, } -impl From for Instructions -where - T: ToString, -{ +impl From for Instructions { fn from(value: T) -> Self { match value.to_string().to_lowercase().as_str() { "uppercase" => Self::Uppercase, @@ -25,10 +22,7 @@ where pub struct Apply(Vec); impl Apply { - pub fn parse(input: T) -> Apply - where - T: ToString, - { + pub fn parse(input: T) -> Apply { Apply( input .to_string() @@ -38,10 +32,7 @@ impl Apply { ) } - pub fn execute(&self, input: T) -> String - where - T: ToString, - { + pub fn execute(&self, input: T) -> String { self.0.iter().fold( input.to_string(), |current, instruction| match instruction {