aboutsummaryrefslogtreecommitdiff
path: root/mingling_core
diff options
context:
space:
mode:
author魏曹先生 <1992414357@qq.com>2026-05-21 15:57:38 +0800
committer魏曹先生 <1992414357@qq.com>2026-05-21 15:57:38 +0800
commitc2edd02745b5bdfcb8a6bb1da64e411e77855cac (patch)
tree934e9703fb3f4b3808bd387229ace101ccbec24b /mingling_core
parent53dc4370345962f2d2c069d5ba263a8efe7ba19f (diff)
Change `repl_post_readline` hook to accept mutable line reference
Diffstat (limited to 'mingling_core')
-rw-r--r--mingling_core/src/program/hook.rs8
-rw-r--r--mingling_core/src/program/repl_exec.rs8
2 files changed, 8 insertions, 8 deletions
diff --git a/mingling_core/src/program/hook.rs b/mingling_core/src/program/hook.rs
index f93b022..3520084 100644
--- a/mingling_core/src/program/hook.rs
+++ b/mingling_core/src/program/hook.rs
@@ -54,7 +54,7 @@ where
/// Executes after reading a REPL line (only available with `repl` feature)
#[cfg(feature = "repl")]
- pub repl_post_readline: Option<fn(line: &str)>,
+ pub repl_post_readline: Option<fn(line: &mut String)>,
/// Executes before executing a REPL command (only available with `repl` feature)
#[cfg(feature = "repl")]
@@ -252,7 +252,7 @@ where
/// Runs the REPL post-readline hooks (only available with `repl` feature)
#[cfg(feature = "repl")]
- pub(crate) fn run_hook_repl_post_readline(&self, line: &str) {
+ pub(crate) fn run_hook_repl_post_readline(&self, line: &mut String) {
if !self.user_context.run_hook {
return;
}
@@ -469,9 +469,9 @@ 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 the line as a `&str`.
+ /// This hook runs after reading a line of input and receives a mutable reference to the line.
#[cfg(feature = "repl")]
- pub fn on_repl_post_readline(mut self, handler: fn(line: &str)) -> Self {
+ pub fn on_repl_post_readline(mut self, handler: fn(line: &mut String)) -> Self {
let _ = self.repl_post_readline.insert(handler);
self
}
diff --git a/mingling_core/src/program/repl_exec.rs b/mingling_core/src/program/repl_exec.rs
index c4232ab..3d82b74 100644
--- a/mingling_core/src/program/repl_exec.rs
+++ b/mingling_core/src/program/repl_exec.rs
@@ -31,8 +31,8 @@ where
self.exec_wrapper(|p| -> () {
loop {
p.run_hook_repl_pre_readline();
- let readline = p.run_hook_repl_readline().unwrap_or_default();
- p.run_hook_repl_post_readline(&readline);
+ let mut readline = p.run_hook_repl_readline().unwrap_or_default();
+ p.run_hook_repl_post_readline(&mut readline);
let args = split_input_string(readline.clone());
@@ -80,8 +80,8 @@ where
self.exec_wrapper(async |p| -> () {
loop {
p.run_hook_repl_pre_readline();
- let readline = p.run_hook_repl_readline().unwrap_or_default();
- p.run_hook_repl_post_readline(&readline);
+ let mut readline = p.run_hook_repl_readline().unwrap_or_default();
+ p.run_hook_repl_post_readline(&mut readline);
let args = split_input_string(readline.clone());