diff options
| author | Weicao-CatilGrass <1992414357@qq.com> | 2026-05-31 02:42:52 +0800 |
|---|---|---|
| committer | 魏曹先生 <1992414357@qq.com> | 2026-05-31 17:19:20 +0800 |
| commit | 2aa7bda3cb21ce6c052b82e08bcab79a625d04f2 (patch) | |
| tree | f10b89007fc67ca1a948f34abe6869b49296b932 /mingling_core/src/program | |
| parent | 3aa409a55e4f2f0ab41b0949cc06eb13c2da4a43 (diff) | |
Enhance code quality across the entire codebase
Diffstat (limited to 'mingling_core/src/program')
| -rw-r--r-- | mingling_core/src/program/collection.rs | 21 | ||||
| -rw-r--r-- | mingling_core/src/program/config.rs | 2 | ||||
| -rw-r--r-- | mingling_core/src/program/error.rs | 5 | ||||
| -rw-r--r-- | mingling_core/src/program/exec.rs | 35 | ||||
| -rw-r--r-- | mingling_core/src/program/exec/error.rs | 23 | ||||
| -rw-r--r-- | mingling_core/src/program/flag.rs | 2 | ||||
| -rw-r--r-- | mingling_core/src/program/hook.rs | 42 | ||||
| -rw-r--r-- | mingling_core/src/program/once_exec.rs | 31 | ||||
| -rw-r--r-- | mingling_core/src/program/repl_exec.rs | 6 | ||||
| -rw-r--r-- | mingling_core/src/program/single_instance.rs | 5 |
10 files changed, 109 insertions, 63 deletions
diff --git a/mingling_core/src/program/collection.rs b/mingling_core/src/program/collection.rs index ff26411..d3d18d6 100644 --- a/mingling_core/src/program/collection.rs +++ b/mingling_core/src/program/collection.rs @@ -25,23 +25,23 @@ pub trait ProgramCollect { /// Use a prefix tree to quickly match arguments and dispatch to an Entry #[cfg(feature = "dispatch_tree")] fn dispatch_args_trie( - raw: &Vec<String>, + raw: &[String], ) -> Result<AnyOutput<Self::Enum>, crate::error::ProgramInternalExecuteError>; /// Get all registered dispatcher names from the program #[cfg(feature = "dispatch_tree")] fn get_nodes() -> Vec<(String, &'static (dyn Dispatcher<Self::Enum> + Send + Sync))>; - /// Build an [AnyOutput](./struct.AnyOutput.html) to indicate that a renderer was not found + /// Build an [`AnyOutput`](./struct.AnyOutput.html) to indicate that a renderer was not found fn build_renderer_not_found(member_id: Self::Enum) -> AnyOutput<Self::Enum>; - /// Build an [AnyOutput](./struct.AnyOutput.html) to indicate that a dispatcher was not found + /// Build an [`AnyOutput`](./struct.AnyOutput.html) to indicate that a dispatcher was not found fn build_dispatcher_not_found(args: Vec<String>) -> AnyOutput<Self::Enum>; - /// Build an [AnyOutput](./struct.AnyOutput.html) to indicate that the chain returned an empty result + /// Build an [`AnyOutput`](./struct.AnyOutput.html) to indicate that the chain returned an empty result fn build_empty_result() -> AnyOutput<Self::Enum>; - /// Render the input [AnyOutput](./struct.AnyOutput.html) + /// Render the input [`AnyOutput`](./struct.AnyOutput.html) fn render(any: AnyOutput<Self::Enum>, r: &mut RenderResult); /// Render help for Entry @@ -53,7 +53,7 @@ pub trait ProgramCollect { any: AnyOutput<Self::Enum>, ) -> Pin<Box<dyn Future<Output = ChainProcess<Self::Enum>> + Send>>; - /// Find a matching chain to continue execution based on the input [AnyOutput](./struct.AnyOutput.html), returning a new [AnyOutput](./struct.AnyOutput.html) + /// Find a matching chain to continue execution based on the input [`AnyOutput`](./struct.AnyOutput.html), returning a new [`AnyOutput`](./struct.AnyOutput.html) #[cfg(not(feature = "async"))] fn do_chain(any: AnyOutput<Self::Enum>) -> ChainProcess<Self::Enum>; @@ -61,13 +61,18 @@ pub trait ProgramCollect { #[cfg(feature = "comp")] fn do_comp(any: &AnyOutput<Self::Enum>, ctx: &ShellContext) -> Suggest; - /// Whether the program has a renderer that can handle the current [AnyOutput](./struct.AnyOutput.html) + /// Whether the program has a renderer that can handle the current [`AnyOutput`](./struct.AnyOutput.html) fn has_renderer(any: &AnyOutput<Self::Enum>) -> bool; - /// Whether the program has a chain that can handle the current [AnyOutput](./struct.AnyOutput.html) + /// Whether the program has a chain that can handle the current [`AnyOutput`](./struct.AnyOutput.html) fn has_chain(any: &AnyOutput<Self::Enum>) -> bool; /// Perform general rendering and presentation of any type + /// + /// # Errors + /// + /// Returns `Err(GeneralRendererSerializeError)` if serialization of the + /// output value fails. #[cfg(feature = "general_renderer")] fn general_render( any: AnyOutput<Self::Enum>, diff --git a/mingling_core/src/program/config.rs b/mingling_core/src/program/config.rs index b5b46a0..5c104ab 100644 --- a/mingling_core/src/program/config.rs +++ b/mingling_core/src/program/config.rs @@ -109,7 +109,7 @@ impl std::str::FromStr for GeneralRendererSetting { "ron" => Ok(GeneralRendererSetting::Ron), #[cfg(feature = "ron_serde_fmt")] "ron-pretty" => Ok(GeneralRendererSetting::RonPretty), - _ => Err(format!("Invalid renderer: '{}'", s)), + _ => Err(format!("Invalid renderer: '{s}'")), } } } diff --git a/mingling_core/src/program/error.rs b/mingling_core/src/program/error.rs index 03e9af6..822e429 100644 --- a/mingling_core/src/program/error.rs +++ b/mingling_core/src/program/error.rs @@ -9,9 +9,9 @@ pub struct ProgramPanic { impl fmt::Display for ProgramPanic { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { if let Some(s) = self.payload.downcast_ref::<&str>() { - write!(f, "{}", s) + write!(f, "{s}") } else if let Some(s) = self.payload.downcast_ref::<String>() { - write!(f, "{}", s) + write!(f, "{s}") } else { write!(f, "") } @@ -19,6 +19,7 @@ impl fmt::Display for ProgramPanic { } impl ProgramPanic { + #[must_use] pub fn new(payload: Box<dyn Any + Send>) -> Self { ProgramPanic { payload } } diff --git a/mingling_core/src/program/exec.rs b/mingling_core/src/program/exec.rs index 72a20b9..0cadc6a 100644 --- a/mingling_core/src/program/exec.rs +++ b/mingling_core/src/program/exec.rs @@ -15,8 +15,7 @@ pub async fn exec<C>( where C: ProgramCollect<Enum = C>, { - let args = program.args.clone(); - exec_with_args(program, args).await + exec_with_args(program, &program.args).await } #[cfg(not(feature = "async"))] @@ -24,26 +23,25 @@ pub fn exec<C>(program: &'static Program<C>) -> Result<RenderResult, ProgramInte where C: ProgramCollect<Enum = C>, { - let args = program.args.clone(); - exec_with_args(program, args) + exec_with_args(program, &program.args) } #[cfg(feature = "async")] pub async fn exec_with_args<C>( program: &'static Program<C>, - args: Vec<String>, + args: &[String], ) -> Result<RenderResult, ProgramInternalExecuteError> where C: ProgramCollect<Enum = C>, { // Run hooks - program.run_hook_pre_dispatch(&args); + program.run_hook_pre_dispatch(args); #[cfg(not(feature = "dispatch_tree"))] - let mut current = dispatch_args_dynamic(program, &args)?; + let mut current = dispatch_args_dynamic(program, args)?; #[cfg(feature = "dispatch_tree")] - let mut current = C::dispatch_args_trie(&args)?; + let mut current = C::dispatch_args_trie(args)?; // Run hook program.run_hook_post_dispatch(¤t.member_id); @@ -125,19 +123,19 @@ where #[cfg(not(feature = "async"))] pub fn exec_with_args<C>( program: &'static Program<C>, - args: Vec<String>, + args: &[String], ) -> Result<RenderResult, ProgramInternalExecuteError> where C: ProgramCollect<Enum = C>, { // Run hooks - program.run_hook_pre_dispatch(&args); + program.run_hook_pre_dispatch(args); #[cfg(not(feature = "dispatch_tree"))] - let mut current = dispatch_args_dynamic(program, &args)?; + let mut current = dispatch_args_dynamic(program, args)?; #[cfg(feature = "dispatch_tree")] - let mut current = C::dispatch_args_trie(&args)?; + let mut current = C::dispatch_args_trie(args)?; // Run hook program.run_hook_post_dispatch(¤t.member_id); @@ -221,7 +219,7 @@ where /// Dynamically dispatch input arguments to registered entry types pub(crate) fn dispatch_args_dynamic<C>( program: &'static Program<C>, - args: &Vec<String>, + args: &[String], ) -> Result<AnyOutput<C>, ProgramInternalExecuteError> where C: ProgramCollect<Enum = C>, @@ -236,7 +234,7 @@ where } Err(ProgramInternalExecuteError::DispatcherNotFound) => { // No matching Dispatcher is found - C::build_dispatcher_not_found(args.clone()) + C::build_dispatcher_not_found(args.to_vec()) } Err(e) => return Err(e), }; @@ -245,10 +243,9 @@ where /// Match user input against registered dispatchers and return the matched dispatcher and remaining arguments. #[allow(clippy::type_complexity)] -#[allow(clippy::ptr_arg)] pub(crate) fn match_user_input<C>( program: &'static Program<C>, - args: &Vec<String>, + args: &[String], ) -> Result<(&'static (dyn Dispatcher<C> + Send + Sync), Vec<String>), ProgramInternalExecuteError> where C: ProgramCollect<Enum = C>, @@ -260,7 +257,7 @@ where let matching_nodes: Vec<&(String, &(dyn Dispatcher<C> + Send + Sync))> = nodes .iter() // Also add a space to the node string to ensure consistent matching logic - .filter(|(node_str, _)| command.starts_with(&format!("{} ", node_str))) + .filter(|(node_str, _)| command.starts_with(&format!("{node_str} "))) .collect(); match matching_nodes.len() { @@ -289,7 +286,7 @@ where } } -#[inline(always)] +#[inline] #[allow(unused_variables)] fn render<C: ProgramCollect<Enum = C>>(program: &Program<C>, any: AnyOutput<C>) -> RenderResult { #[cfg(not(feature = "general_renderer"))] @@ -312,7 +309,7 @@ fn render<C: ProgramCollect<Enum = C>>(program: &Program<C>, any: AnyOutput<C>) } } -#[inline(always)] +#[inline] #[allow(unused_variables)] fn render_help<C: ProgramCollect<Enum = C>>( program: &Program<C>, diff --git a/mingling_core/src/program/exec/error.rs b/mingling_core/src/program/exec/error.rs index 0f2d875..944e89a 100644 --- a/mingling_core/src/program/exec/error.rs +++ b/mingling_core/src/program/exec/error.rs @@ -26,10 +26,10 @@ impl fmt::Display for ProgramExecuteError { match self { ProgramExecuteError::DispatcherNotFound => write!(f, "No Dispatcher Found"), ProgramExecuteError::RendererNotFound(s) => { - write!(f, "No Renderer (`{}`) Found", s) + write!(f, "No Renderer (`{s}`) Found") } - ProgramExecuteError::Panic(p) => write!(f, "Panic: {:?}", p), - ProgramExecuteError::Other(s) => write!(f, "Other error: {}", s), + ProgramExecuteError::Panic(p) => write!(f, "Panic: {p:?}"), + ProgramExecuteError::Other(s) => write!(f, "Other error: {s}"), } } } @@ -74,12 +74,12 @@ impl fmt::Display for ProgramInternalExecuteError { write!(f, "No Dispatcher Found") } ProgramInternalExecuteError::RendererNotFound(s) => { - write!(f, "No Renderer (`{}`) Found", s) + write!(f, "No Renderer (`{s}`) Found") } - ProgramInternalExecuteError::Other(s) => write!(f, "Other error: {}", s), - ProgramInternalExecuteError::IO(e) => write!(f, "IO error: {}", e), + ProgramInternalExecuteError::Other(s) => write!(f, "Other error: {s}"), + ProgramInternalExecuteError::IO(e) => write!(f, "IO error: {e}"), ProgramInternalExecuteError::REPLPanic(panic) => { - write!(f, "A single REPL execution failed: {}", panic) + write!(f, "A single REPL execution failed: {panic}") } } } @@ -110,11 +110,10 @@ impl From<ProgramInternalExecuteError> for ProgramExecuteError { ProgramExecuteError::RendererNotFound(s) } ProgramInternalExecuteError::Other(s) => ProgramExecuteError::Other(s), - ProgramInternalExecuteError::IO(e) => ProgramExecuteError::Other(format!("{}", e)), - ProgramInternalExecuteError::REPLPanic(p) => ProgramExecuteError::Other(format!( - "A single REPL execution failed: {}", - p - )), + ProgramInternalExecuteError::IO(e) => ProgramExecuteError::Other(format!("{e}")), + ProgramInternalExecuteError::REPLPanic(p) => { + ProgramExecuteError::Other(format!("A single REPL execution failed: {p}")) + } } } } diff --git a/mingling_core/src/program/flag.rs b/mingling_core/src/program/flag.rs index 210f2d6..13f6ea9 100644 --- a/mingling_core/src/program/flag.rs +++ b/mingling_core/src/program/flag.rs @@ -51,7 +51,7 @@ impl From<&Flag> for Flag { } impl From<()> for Flag { - fn from(_: ()) -> Self { + fn from((): ()) -> Self { Flag { vec: vec![] } } } diff --git a/mingling_core/src/program/hook.rs b/mingling_core/src/program/hook.rs index 3520084..929eac2 100644 --- a/mingling_core/src/program/hook.rs +++ b/mingling_core/src/program/hook.rs @@ -16,7 +16,7 @@ where pub begin: Option<fn()>, /// Executes before the program dispatches - pub pre_dispatch: Option<fn(args: &Vec<String>)>, + pub pre_dispatch: Option<fn(args: &[String])>, /// Executes after the program dispatches pub post_dispatch: Option<fn(entry: &C)>, @@ -98,19 +98,19 @@ where for hook in &self.hooks { if let Some(begin) = hook.begin { - begin() + begin(); } } } - pub(crate) fn run_hook_pre_dispatch(&self, args: &Vec<String>) { + pub(crate) fn run_hook_pre_dispatch(&self, args: &[String]) { if !self.user_context.run_hook { return; } for hook in &self.hooks { if let Some(pre_dispatch) = hook.pre_dispatch { - pre_dispatch(args) + pre_dispatch(args); } } } @@ -122,7 +122,7 @@ where for hook in &self.hooks { if let Some(post_dispatch) = hook.post_dispatch { - post_dispatch(entry) + post_dispatch(entry); } } } @@ -134,7 +134,7 @@ where for hook in &self.hooks { if let Some(pre_chain) = hook.pre_chain { - pre_chain(input, raw) + pre_chain(input, raw); } } } @@ -146,7 +146,7 @@ where for hook in &self.hooks { if let Some(post_chain) = hook.post_chain { - post_chain(output) + post_chain(output); } } } @@ -158,7 +158,7 @@ where for hook in &self.hooks { if let Some(pre_render) = hook.pre_render { - pre_render(input, raw) + pre_render(input, raw); } } } @@ -170,7 +170,7 @@ where for hook in &self.hooks { if let Some(post_render) = hook.post_render { - post_render(result) + post_render(result); } } } @@ -184,7 +184,7 @@ where for hook in &self.hooks { if let Some(exec_panic) = hook.exec_panic { - exec_panic(panic_info) + exec_panic(panic_info); } } } @@ -354,6 +354,7 @@ where C: ProgramCollect<Enum = C>, { /// Creates a new empty hook set with no handlers. + #[must_use] pub fn empty() -> Self { Self { begin: None, @@ -390,48 +391,56 @@ where } /// Sets the handler for the `begin` event. + #[must_use] pub fn on_begin(mut self, handler: fn()) -> Self { let _ = self.begin.insert(handler); self } /// Sets the handler for the `pre_dispatch` event. - pub fn on_pre_dispatch(mut self, handler: fn(args: &Vec<String>)) -> Self { + #[must_use] + pub fn on_pre_dispatch(mut self, handler: fn(args: &[String])) -> Self { let _ = self.pre_dispatch.insert(handler); self } /// Sets the handler for the `post_dispatch` event. + #[must_use] pub fn on_post_dispatch(mut self, handler: fn(entry: &C)) -> Self { let _ = self.post_dispatch.insert(handler); self } /// Sets the handler for the `pre_chain` event. + #[must_use] pub fn on_pre_chain(mut self, handler: fn(input: &C, raw: &dyn Any)) -> Self { let _ = self.pre_chain.insert(handler); self } /// Sets the handler for the `post_chain` event. + #[must_use] pub fn on_post_chain(mut self, handler: fn(output: &AnyOutput<C>)) -> Self { let _ = self.post_chain.insert(handler); self } /// Sets the handler for the `pre_render` event. + #[must_use] pub fn on_pre_render(mut self, handler: fn(input: &C, raw: &dyn Any)) -> Self { let _ = self.pre_render.insert(handler); self } /// Sets the handler for the `post_render` event. + #[must_use] pub fn on_post_render(mut self, handler: fn(result: &RenderResult)) -> Self { let _ = self.post_render.insert(handler); self } /// Sets the handler for the `finish` event. + #[must_use] pub fn on_finish(mut self, handler: fn() -> i32) -> Self { let _ = self.finish.insert(handler); self @@ -439,6 +448,7 @@ where /// Sets the handler for the `exec_panic` event. #[cfg(not(feature = "async"))] + #[must_use] pub fn on_exec_panic(mut self, handler: fn(&ProgramPanic)) -> Self { let _ = self.exec_panic.insert(handler); self @@ -446,6 +456,7 @@ where /// Sets the handler for the REPL begin event (only available with `repl` feature). #[cfg(feature = "repl")] + #[must_use] pub fn on_repl_begin(mut self, handler: fn()) -> Self { let _ = self.repl_on_begin.insert(handler); self @@ -454,6 +465,7 @@ where /// Sets the handler for the REPL pre-readline event (only available with `repl` feature). /// This hook runs after `on_repl_begin` but before reading the next input line. #[cfg(feature = "repl")] + #[must_use] pub fn on_repl_pre_readline(mut self, handler: fn()) -> Self { let _ = self.repl_pre_readline.insert(handler); self @@ -463,6 +475,7 @@ where /// If set, this function will be called to read a line instead of the default mechanism. /// Returning `None` signals that there is no input (e.g., EOF). #[cfg(feature = "repl")] + #[must_use] pub fn on_repl_readline(mut self, handler: fn() -> Option<String>) -> Self { let _ = self.repl_readline.insert(handler); self @@ -471,6 +484,7 @@ where /// Sets the handler for the REPL post-readline event (only available with `repl` feature). /// This hook runs after reading a line of input and receives a mutable reference to the line. #[cfg(feature = "repl")] + #[must_use] pub fn on_repl_post_readline(mut self, handler: fn(line: &mut String)) -> Self { let _ = self.repl_post_readline.insert(handler); self @@ -479,6 +493,7 @@ where /// Sets the handler for the REPL pre-exec event (only available with `repl` feature). /// This hook runs before executing a REPL command, receiving the parsed arguments. #[cfg(feature = "repl")] + #[must_use] pub fn on_repl_pre_exec(mut self, handler: fn(args: &[String])) -> Self { let _ = self.repl_pre_exec.insert(handler); self @@ -487,6 +502,7 @@ where /// Sets the handler for the REPL post-exec event (only available with `repl` feature). /// This hook runs after executing a REPL command. #[cfg(feature = "repl")] + #[must_use] pub fn on_repl_post_exec(mut self, handler: fn()) -> Self { let _ = self.repl_post_exec.insert(handler); self @@ -495,6 +511,7 @@ where /// Sets the handler for the REPL receive result event (only available with `repl` feature). /// This hook runs after a command is executed, receiving the render result on success. #[cfg(feature = "repl")] + #[must_use] pub fn on_repl_receive_result(mut self, handler: fn(result: &RenderResult)) -> Self { let _ = self.repl_on_receive_result.insert(handler); self @@ -502,6 +519,7 @@ where /// Sets the handler for the REPL panic event (only available with `repl` feature). #[cfg(all(feature = "repl", not(feature = "async")))] + #[must_use] pub fn on_repl_panic(mut self, handler: fn(panic: &ProgramPanic)) -> Self { let _ = self.repl_on_panic.insert(handler); self @@ -510,6 +528,7 @@ where /// Sets the handler for the REPL exit event (only available with `repl` feature). /// This hook runs when the REPL is about to exit. #[cfg(feature = "repl")] + #[must_use] pub fn on_repl_exit(mut self, handler: fn()) -> Self { let _ = self.repl_exit.insert(handler); self @@ -518,6 +537,7 @@ where /// Sets the handler for the REPL loop_once event (only available with `repl` feature). /// This hook runs after each REPL loop iteration. #[cfg(feature = "repl")] + #[must_use] pub fn on_repl_loop_once(mut self, handler: fn()) -> Self { let _ = self.repl_loop_once.insert(handler); self diff --git a/mingling_core/src/program/once_exec.rs b/mingling_core/src/program/once_exec.rs index e1c0956..f757893 100644 --- a/mingling_core/src/program/once_exec.rs +++ b/mingling_core/src/program/once_exec.rs @@ -29,6 +29,15 @@ where } /// Run the command line program + /// + /// # Errors + /// + /// Returns `Err(ProgramExecuteError)` if execution fails, + /// e.g., if no dispatcher is found or a chain error occurs. + /// + /// # Panics + /// + /// Panics if the program encounters a non-recoverable internal error. pub async fn exec_without_render(mut self) -> Result<RenderResult, ProgramExecuteError> where C: 'static + Send + Sync, @@ -127,6 +136,15 @@ where } /// Run the command line program + /// + /// # Errors + /// + /// Returns `Err(ProgramExecuteError)` if execution fails, + /// e.g., if no dispatcher is found or a chain error occurs. + /// + /// # Panics + /// + /// Panics if the program encounters a non-recoverable internal error. pub fn exec_without_render(mut self) -> Result<RenderResult, ProgramExecuteError> where C: 'static + Send + Sync, @@ -141,7 +159,7 @@ where #[cfg(not(panic = "abort"))] match std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { - self.exec_wrapper(|p| crate::exec::exec(p).map_err(|e| e.into())) + self.exec_wrapper(|p| crate::exec::exec(p).map_err(std::convert::Into::into)) })) { Ok(result) => result, Err(panic_info) => { @@ -164,6 +182,7 @@ where } /// Run the command line program + #[must_use] pub fn exec(self) -> i32 where C: 'static + Send + Sync, @@ -179,15 +198,15 @@ where return 1; } ProgramExecuteError::RendererNotFound(renderer_name) => { - eprintln!("Renderer `{}` not found", renderer_name); + eprintln!("Renderer `{renderer_name}` not found"); return 1; } ProgramExecuteError::Other(e) => { - eprintln!("{}", e); + eprintln!("{e}"); return 1; } ProgramExecuteError::Panic(unwinded_error) => { - eprintln!("{}", unwinded_error); + eprintln!("{unwinded_error}"); return 1; } }, @@ -196,12 +215,12 @@ where // Render result if stdout_setting.render_output && !result.is_empty() { let exit_code = result.exit_code; - print!("{}", result); + print!("{result}"); if let Err(e) = std::io::Write::flush(&mut std::io::stdout()) && stdout_setting.error_output { - eprintln!("{}", e); + eprintln!("{e}"); 1 } else { exit_code diff --git a/mingling_core/src/program/repl_exec.rs b/mingling_core/src/program/repl_exec.rs index 3d82b74..d7ee8e8 100644 --- a/mingling_core/src/program/repl_exec.rs +++ b/mingling_core/src/program/repl_exec.rs @@ -115,12 +115,12 @@ where C: ProgramCollect<Enum = C> + Send + Sync + 'static, { #[cfg(panic = "abort")] - let exec_result = super::exec::exec_with_args(p, args); + let exec_result = super::exec::exec_with_args(p, &args); #[cfg(not(panic = "abort"))] let exec_result = { let exec_unwind_result = std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { - super::exec::exec_with_args(p, args) + super::exec::exec_with_args(p, &args) })); match exec_unwind_result { @@ -153,5 +153,5 @@ async fn exec_once<C>( where C: ProgramCollect<Enum = C> + Send + Sync + 'static, { - super::exec::exec_with_args(p, args).await + super::exec::exec_with_args(p, &args).await } diff --git a/mingling_core/src/program/single_instance.rs b/mingling_core/src/program/single_instance.rs index 45d4d33..70771d5 100644 --- a/mingling_core/src/program/single_instance.rs +++ b/mingling_core/src/program/single_instance.rs @@ -7,6 +7,11 @@ pub(crate) static THIS_PROGRAM: OnceLock<Option<Box<dyn std::any::Any + Send + S OnceLock::new(); /// Returns a reference to the current program instance, panics if not set. +/// +/// # Panics +/// +/// Panics if the program has not been initialized yet. +#[must_use] pub fn this<C>() -> &'static Program<C> where C: ProgramCollect<Enum = C> + 'static, |
