Skip to content

Commit

Permalink
Merge pull request #110 from mobusoperandi/as_char_early
Browse files Browse the repository at this point in the history
refactor: ch as char early
  • Loading branch information
mightyiam authored Jun 9, 2024
2 parents 3a822d8 + 6a58de3 commit 3eca8ce
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/app/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,13 +123,14 @@ impl State {
}

fn repl_event_read(&mut self, id: ExampleId, ch: u8) -> anyhow::Result<Vec<OutputEvent>> {
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> ") {
Expand All @@ -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() {
Expand All @@ -161,7 +162,7 @@ impl State {
acc,
expected_result,
} => 'arm: {
acc.push(ch.into());
acc.push(ch);

let sanitized = Self::sanitize(acc)?;

Expand Down

0 comments on commit 3eca8ce

Please sign in to comment.