From 97fc7de6754c8b5c383d7d5e3f9e26b3bbfb08fb Mon Sep 17 00:00:00 2001 From: Anthony Rubick <68485672+AnthonyMichaelTDM@users.noreply.github.com> Date: Sun, 9 Jul 2023 20:07:09 -0700 Subject: fix: minor code cleanup and pedantic lints (#134) --- src/repl/handler.rs | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'src/repl/handler.rs') diff --git a/src/repl/handler.rs b/src/repl/handler.rs index 495413c..2057b8b 100644 --- a/src/repl/handler.rs +++ b/src/repl/handler.rs @@ -24,6 +24,7 @@ pub enum ReplCmd { Copy, } +#[allow(clippy::module_name_repetitions)] pub struct ReplCmdHandler { client: ChatGptClient, config: SharedConfig, @@ -32,6 +33,7 @@ pub struct ReplCmdHandler { } impl ReplCmdHandler { + #[allow(clippy::unnecessary_wraps)] pub fn init( client: ChatGptClient, config: SharedConfig, @@ -58,7 +60,7 @@ impl ReplCmdHandler { let ret = render_stream( &input, &self.client, - self.config.clone(), + &self.config, true, self.abort.clone(), wg.clone(), @@ -113,6 +115,7 @@ impl ReplCmdHandler { } } +#[allow(clippy::module_name_repetitions)] pub struct ReplyStreamHandler { sender: Option>, buffer: String, @@ -154,22 +157,19 @@ impl ReplyStreamHandler { } pub fn done(&mut self) -> Result<()> { - match self.sender.as_ref() { - Some(tx) => { - let ret = tx - .send(ReplyStreamEvent::Done) - .with_context(|| "Failed to send StreamEvent:Done"); - self.safe_ret(ret)?; + if let Some(tx) = self.sender.as_ref() { + let ret = tx + .send(ReplyStreamEvent::Done) + .with_context(|| "Failed to send StreamEvent:Done"); + self.safe_ret(ret)?; + } else { + if !self.buffer.ends_with('\n') { + print_now!("\n"); } - None => { - if !self.buffer.ends_with('\n') { - print_now!("\n") - } - if self.repl { + if self.repl { + print_now!("\n"); + if cfg!(macos) { print_now!("\n"); - if cfg!(macos) { - print_now!("\n") - } } } } -- cgit v1.2.3