diff options
| author | sigoden <sigoden@gmail.com> | 2023-11-07 10:21:17 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-11-07 10:21:17 +0800 |
| commit | 87aec71e080dc9c15f3dd0059dbc91686f3de4e6 (patch) | |
| tree | 962ade482812d222d0681af6e4f5de946e3c86cf /src/repl | |
| parent | 81624f7267ba20799a3bbf779abfe41df30d349c (diff) | |
| download | aichat-87aec71e080dc9c15f3dd0059dbc91686f3de4e6.tar.gz | |
refactor: use &GlobalConfig to avoid clone (#217)
Diffstat (limited to 'src/repl')
| -rw-r--r-- | src/repl/mod.rs | 10 | ||||
| -rw-r--r-- | src/repl/prompt.rs | 6 |
2 files changed, 9 insertions, 7 deletions
diff --git a/src/repl/mod.rs b/src/repl/mod.rs index 818a86a..4f51020 100644 --- a/src/repl/mod.rs +++ b/src/repl/mod.rs @@ -60,17 +60,17 @@ pub struct Repl { } impl Repl { - pub fn init(config: GlobalConfig) -> Result<Self> { - let editor = Self::create_editor(&config)?; + pub fn init(config: &GlobalConfig) -> Result<Self> { + let editor = Self::create_editor(config)?; - let prompt = ReplPrompt::new(config.clone()); + let prompt = ReplPrompt::new(config); let abort = create_abort_signal(); let clipboard = Clipboard::new().map(RefCell::new); Ok(Self { - config, + config: config.clone(), editor, prompt, clipboard, @@ -228,7 +228,7 @@ impl Repl { } self.config.read().maybe_print_send_tokens(input); let wg = WaitGroup::new(); - let client = init_client(self.config.clone())?; + let client = init_client(&self.config)?; let ret = render_stream( input, client.as_ref(), diff --git a/src/repl/prompt.rs b/src/repl/prompt.rs index b4c9099..827f84d 100644 --- a/src/repl/prompt.rs +++ b/src/repl/prompt.rs @@ -15,8 +15,10 @@ pub struct ReplPrompt { } impl ReplPrompt { - pub fn new(config: GlobalConfig) -> Self { - Self { config } + pub fn new(config: &GlobalConfig) -> Self { + Self { + config: config.clone(), + } } } |
