diff options
| author | 魏曹先生 <1992414357@qq.com> | 2026-03-29 15:00:09 +0800 |
|---|---|---|
| committer | 魏曹先生 <1992414357@qq.com> | 2026-03-29 15:00:09 +0800 |
| commit | 586c206e50bb8e9a1376f65975f1c9916b1cde7e (patch) | |
| tree | 7d416ad11b65ab27d3dbf056dfccc1c1cfcde4c4 | |
| parent | 338361a8fca469745454e0f067c93739542d4ff0 (diff) | |
Apply clippy fixes
| -rw-r--r-- | mingling/src/asset/dispatcher.rs | 6 | ||||
| -rw-r--r-- | mingling/src/program.rs | 7 | ||||
| -rw-r--r-- | mingling/src/program/config.rs | 9 | ||||
| -rw-r--r-- | mingling/src/program/exec.rs | 19 | ||||
| -rw-r--r-- | mingling/src/program/exec/error.rs | 2 | ||||
| -rw-r--r-- | mingling/src/program/flag.rs | 2 | ||||
| -rw-r--r-- | mingling/src/program/hint.rs | 2 |
7 files changed, 19 insertions, 28 deletions
diff --git a/mingling/src/asset/dispatcher.rs b/mingling/src/asset/dispatcher.rs index 09bd386..13e35f7 100644 --- a/mingling/src/asset/dispatcher.rs +++ b/mingling/src/asset/dispatcher.rs @@ -188,8 +188,8 @@ impl std::ops::Deref for Dispatchers { } } -impl Into<Vec<Box<dyn Dispatcher + 'static>>> for Dispatchers { - fn into(self) -> Vec<Box<dyn Dispatcher + 'static>> { - self.dispatcher +impl From<Dispatchers> for Vec<Box<dyn Dispatcher + 'static>> { + fn from(val: Dispatchers) -> Self { + val.dispatcher } } diff --git a/mingling/src/program.rs b/mingling/src/program.rs index 3394a38..9463084 100644 --- a/mingling/src/program.rs +++ b/mingling/src/program.rs @@ -65,16 +65,15 @@ where }; // Render result - if stdout_setting.render_output { - if !result.is_empty() { + if stdout_setting.render_output + && !result.is_empty() { print!("{}", result); if let Err(e) = tokio::io::stdout().flush().await && stdout_setting.error_output { - eprintln!("{}", e.to_string()); + eprintln!("{}", e); } } - } } } diff --git a/mingling/src/program/config.rs b/mingling/src/program/config.rs index ffcade3..5877abc 100644 --- a/mingling/src/program/config.rs +++ b/mingling/src/program/config.rs @@ -17,6 +17,7 @@ impl Default for ProgramStdoutSetting { } #[derive(Debug, Clone)] +#[derive(Default)] pub struct ProgramUserContext { /// View help information instead of running the command pub help: bool, @@ -25,11 +26,3 @@ pub struct ProgramUserContext { pub confirm: bool, } -impl Default for ProgramUserContext { - fn default() -> Self { - ProgramUserContext { - help: false, - confirm: false, - } - } -} diff --git a/mingling/src/program/exec.rs b/mingling/src/program/exec.rs index 04ed16d..ccdb17b 100644 --- a/mingling/src/program/exec.rs +++ b/mingling/src/program/exec.rs @@ -1,3 +1,5 @@ +#![allow(clippy::borrowed_box)] + use crate::{ AnyOutput, ChainProcess, Dispatcher, Program, ProgramCollect, RenderResult, error::{ChainProcessError, ProgramInternalExecuteError}, @@ -48,14 +50,13 @@ pub async fn exec<C: ProgramCollect>( // If no renderer exists, transfer to the RendererNotFound Dispatcher for execution else { let disp: Box<dyn Dispatcher> = Box::new(RendererNotFound); - let any = match handle_chain_process::<C>( - disp.begin(vec![format!("{:?}", current.type_id)]), - ) { + + match handle_chain_process::<C>(disp.begin(vec![format!("{:?}", current.type_id)])) + { Ok(Next::AnyOutput(any)) => any, Ok(Next::RenderResult(result)) => return Ok(result), Err(e) => return Err(e), - }; - any + } } }; if current.is::<ProgramEnd>() || current.is::<NoChainFound>() { @@ -70,7 +71,7 @@ pub async fn exec<C: ProgramCollect>( fn match_user_input<C: ProgramCollect>( program: &Program<C>, ) -> Result<(&Box<dyn Dispatcher>, Vec<String>), ProgramInternalExecuteError> { - let nodes = get_nodes(&program); + let nodes = get_nodes(program); let command = format!("{} ", program.args.join(" ")); // Find all nodes that match the command prefix @@ -121,11 +122,9 @@ fn handle_chain_process<C: ProgramCollect>( Err(e) => match e { ChainProcessError::Broken(any_output) => { let render_result = render::<C>(any_output); - return Ok(Next::RenderResult(render_result)); - } - _ => { - return Err(e.into()); + Ok(Next::RenderResult(render_result)) } + _ => Err(e.into()), }, } } diff --git a/mingling/src/program/exec/error.rs b/mingling/src/program/exec/error.rs index 0523ea5..8ce16ff 100644 --- a/mingling/src/program/exec/error.rs +++ b/mingling/src/program/exec/error.rs @@ -38,7 +38,7 @@ impl From<ChainProcessError> for ProgramInternalExecuteError { match value { ChainProcessError::Other(s) => ProgramInternalExecuteError::Other(s), ChainProcessError::IO(error) => ProgramInternalExecuteError::IO(error), - ChainProcessError::Broken(_) => ProgramInternalExecuteError::Other(format!("Broken")), + ChainProcessError::Broken(_) => ProgramInternalExecuteError::Other("Broken".to_string()), } } } diff --git a/mingling/src/program/flag.rs b/mingling/src/program/flag.rs index 8372517..3a678be 100644 --- a/mingling/src/program/flag.rs +++ b/mingling/src/program/flag.rs @@ -143,6 +143,6 @@ where return enabled; } } - return false; + false } } diff --git a/mingling/src/program/hint.rs b/mingling/src/program/hint.rs index bf35fea..f8eb01e 100644 --- a/mingling/src/program/hint.rs +++ b/mingling/src/program/hint.rs @@ -73,7 +73,7 @@ impl Dispatcher for RendererNotFound { fn begin(&self, args: Vec<String>) -> ChainProcess { AnyOutput::new(NoRendererFound { - type_to_render: args.get(0).unwrap().clone(), + type_to_render: args.first().unwrap().clone(), }) .route_renderer() } |
