From 6a58de34a13409674de272dfbdda235d72f20f7e Mon Sep 17 00:00:00 2001 From: "Shahar \"Dawn\" Or" Date: Sun, 9 Jun 2024 21:45:10 +0700 Subject: [PATCH] refactor: ch as char early --- src/app/state.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/app/state.rs b/src/app/state.rs index 7e7a42d..7f9c2d5 100644 --- a/src/app/state.rs +++ b/src/app/state.rs @@ -123,13 +123,14 @@ impl State { } fn repl_event_read(&mut self, id: ExampleId, ch: u8) -> anyhow::Result> { + let ch = ch as char; let session_live = self.examples.get_mut_repl(&id)?; let session_live = session_live.state.live_mut()?; let output = match &mut session_live.expecting { - ReplSessionExpecting::Nothing => anyhow::bail!("not expecting, got {:?}", ch as char), + ReplSessionExpecting::Nothing => anyhow::bail!("not expecting, got {:?}", ch), ReplSessionExpecting::Prompt(acc) => { - acc.push(ch.into()); + acc.push(ch); let string = String::from_utf8(strip_ansi_escapes::strip(acc)?)?; if string.ends_with("nix-repl> ") { @@ -144,7 +145,7 @@ impl State { last_query: expected, expected_result, } => { - acc.push(ch.into()); + acc.push(ch); if !acc.ends_with('\n') { vec![] } else if Self::sanitize(acc)? == expected.as_str() { @@ -161,7 +162,7 @@ impl State { acc, expected_result, } => 'arm: { - acc.push(ch.into()); + acc.push(ch); let sanitized = Self::sanitize(acc)?;