Refactor a bit

This commit is contained in:
Edwin Cheng 2020-04-24 09:27:37 +08:00
parent 1627b55028
commit a83d1743a5

View File

@ -5,14 +5,7 @@ use ra_proc_macro::msg::{self, Message};
use std::io;
pub fn run() -> io::Result<()> {
loop {
// bubble up the error for read request,
// as the stdin pipe may be closed.
let req = match read_request()? {
None => continue,
Some(req) => req,
};
while let Some(req) = read_request()? {
let res = match req {
msg::Request::ListMacro(task) => Ok(msg::Response::ListMacro(list_macros(&task))),
msg::Request::ExpansionMacro(task) => {
@ -31,6 +24,8 @@ pub fn run() -> io::Result<()> {
eprintln!("Write message error: {}", err);
}
}
Ok(())
}
fn read_request() -> io::Result<Option<msg::Request>> {