Skip to content

Commit

Permalink
remove unneeded macro
Browse files Browse the repository at this point in the history
  • Loading branch information
geremachek committed Sep 16, 2021
1 parent 99f3ebd commit 74ace13
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "merlin"
version = "1.4.1"
version = "1.4.2"
authors = ["geremachek <mrender2005@gmail.com>"]
edition = "2018"

Expand Down
18 changes: 8 additions & 10 deletions src/plane/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,6 @@ use crate::util;
use super::{Plane, Vision};
use std::io::{self, Write, BufRead};

// flush stdout, handling errors

macro_rules! flush_stdout {
() => {
util::err_msg(io::stdout().flush(), "unable to flush stdout")
}
}

impl Plane {
pub fn repl(&mut self) {
let mut input = String::new();
Expand All @@ -22,7 +14,7 @@ impl Plane {
Vision::Scribe => self.parse_line(";scribe-prompt"),
};

flush_stdout!(); // flush stdout, handling any errors
flush_stdout(); // flush stdout, handling any errors
util::err_msg(io::stdin().read_line(&mut input), "unable to read line"); // read a line of input (handle any errors)

// parse our line, stripping newlines
Expand All @@ -38,7 +30,7 @@ impl Plane {
self.parse_line(strip_nl(&line
.expect(&format!("{} {}", util::ERROR_PREFIX, "can't read stdin"))));

flush_stdout!();
flush_stdout();

if !self.running {
break;
Expand All @@ -54,3 +46,9 @@ fn strip_nl(input: &str) -> &str {
.or_else(|| input.strip_suffix("\n"))
.unwrap_or(&input)
}

// flush stdout, handling errors

fn flush_stdout() {
util::err_msg(io::stdout().flush(), "unable to flush stdout")
}
2 changes: 1 addition & 1 deletion src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
pub const ERROR_PREFIX: &str = "merlin:";

pub fn err_msg<T, E>(res: Result<T, E>, msg: &str) {
if let Err(_) = res {
if res.is_err() {
eprintln!("{} {}", ERROR_PREFIX, msg);
}
}

0 comments on commit 74ace13

Please sign in to comment.