summaryrefslogtreecommitdiff
path: root/mingling/src/program
diff options
context:
space:
mode:
author魏曹先生 <1992414357@qq.com>2026-03-29 15:00:09 +0800
committer魏曹先生 <1992414357@qq.com>2026-03-29 15:00:09 +0800
commit586c206e50bb8e9a1376f65975f1c9916b1cde7e (patch)
tree7d416ad11b65ab27d3dbf056dfccc1c1cfcde4c4 /mingling/src/program
parent338361a8fca469745454e0f067c93739542d4ff0 (diff)
Apply clippy fixes
Diffstat (limited to 'mingling/src/program')
-rw-r--r--mingling/src/program/config.rs9
-rw-r--r--mingling/src/program/exec.rs19
-rw-r--r--mingling/src/program/exec/error.rs2
-rw-r--r--mingling/src/program/flag.rs2
-rw-r--r--mingling/src/program/hint.rs2
5 files changed, 13 insertions, 21 deletions
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()
}