From 535bd7ccf73bcea549ddb7b01e7b3c4f35c6e856 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sun, 12 Aug 2018 22:23:44 +0300 Subject: remove useless loop --- crates/server/src/main.rs | 45 +++++++++++++++++++++------------------------ 1 file changed, 21 insertions(+), 24 deletions(-) (limited to 'crates/server/src') diff --git a/crates/server/src/main.rs b/crates/server/src/main.rs index fccfe9b3b..4b250acfa 100644 --- a/crates/server/src/main.rs +++ b/crates/server/src/main.rs @@ -72,33 +72,30 @@ fn main_inner() -> Result<()> { } fn initialize(io: &mut Io) -> Result<()> { - loop { - match io.recv()? { - RawMsg::Notification(n) => - bail!("expected initialize request, got {:?}", n), - RawMsg::Response(res) => - bail!("expected initialize request, got {:?}", res), + match io.recv()? { + RawMsg::Notification(n) => + bail!("expected initialize request, got {:?}", n), + RawMsg::Response(res) => + bail!("expected initialize request, got {:?}", res), - RawMsg::Request(req) => { - let mut req = Some(req); - dispatch::handle_request::(&mut req, |_params, resp| { - let res = req::InitializeResult { capabilities: caps::SERVER_CAPABILITIES }; - let resp = resp.into_response(Ok(res))?; - io.send(RawMsg::Response(resp)); - Ok(()) - })?; - if let Some(req) = req { - bail!("expected initialize request, got {:?}", req) - } - match io.recv()? { - RawMsg::Notification(n) => { - if n.method != "initialized" { - bail!("expected initialized notification"); - } + RawMsg::Request(req) => { + let mut req = Some(req); + dispatch::handle_request::(&mut req, |_params, resp| { + let res = req::InitializeResult { capabilities: caps::SERVER_CAPABILITIES }; + let resp = resp.into_response(Ok(res))?; + io.send(RawMsg::Response(resp)); + Ok(()) + })?; + if let Some(req) = req { + bail!("expected initialize request, got {:?}", req) + } + match io.recv()? { + RawMsg::Notification(n) => { + if n.method != "initialized" { + bail!("expected initialized notification"); } - _ => bail!("expected initialized notification"), } - break; + _ => bail!("expected initialized notification"), } } } -- cgit v1.2.3