From 12e3b4c70b5ef23b2fdfc197296d483680e125f9 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 8 Feb 2019 14:49:43 +0300 Subject: reformat the world --- crates/gen_lsp_server/src/msg.rs | 39 ++++++++------------------------------ crates/gen_lsp_server/src/stdio.rs | 4 +--- 2 files changed, 9 insertions(+), 34 deletions(-) (limited to 'crates/gen_lsp_server') diff --git a/crates/gen_lsp_server/src/msg.rs b/crates/gen_lsp_server/src/msg.rs index 818111fe7..02c7a1858 100644 --- a/crates/gen_lsp_server/src/msg.rs +++ b/crates/gen_lsp_server/src/msg.rs @@ -80,10 +80,7 @@ impl RawMessage { #[serde(flatten)] msg: RawMessage, } - let text = to_string(&JsonRpc { - jsonrpc: "2.0", - msg: self, - })?; + let text = to_string(&JsonRpc { jsonrpc: "2.0", msg: self })?; write_msg_text(w, &text)?; Ok(()) } @@ -95,11 +92,7 @@ impl RawRequest { R: Request, R::Params: serde::Serialize, { - RawRequest { - id, - method: R::METHOD.to_string(), - params: to_value(params).unwrap(), - } + RawRequest { id, method: R::METHOD.to_string(), params: to_value(params).unwrap() } } pub fn cast(self) -> ::std::result::Result<(u64, R::Params), RawRequest> where @@ -121,23 +114,11 @@ impl RawResponse { R: Request, R::Result: serde::Serialize, { - RawResponse { - id, - result: Some(to_value(&result).unwrap()), - error: None, - } + RawResponse { id, result: Some(to_value(&result).unwrap()), error: None } } pub fn err(id: u64, code: i32, message: String) -> RawResponse { - let error = RawResponseError { - code, - message, - data: None, - }; - RawResponse { - id, - result: None, - error: Some(error), - } + let error = RawResponseError { code, message, data: None }; + RawResponse { id, result: None, error: Some(error) } } } @@ -147,10 +128,7 @@ impl RawNotification { N: Notification, N::Params: serde::Serialize, { - RawNotification { - method: N::METHOD.to_string(), - params: to_value(params).unwrap(), - } + RawNotification { method: N::METHOD.to_string(), params: to_value(params).unwrap() } } pub fn is(&self) -> bool where @@ -187,9 +165,8 @@ fn read_msg_text(inp: &mut impl BufRead) -> Result> { } let mut parts = buf.splitn(2, ": "); let header_name = parts.next().unwrap(); - let header_value = parts - .next() - .ok_or_else(|| format_err!("malformed header: {:?}", buf))?; + let header_value = + parts.next().ok_or_else(|| format_err!("malformed header: {:?}", buf))?; if header_name == "Content-Length" { size = Some(header_value.parse::()?); } diff --git a/crates/gen_lsp_server/src/stdio.rs b/crates/gen_lsp_server/src/stdio.rs index 5c8e33854..dab2d8da8 100644 --- a/crates/gen_lsp_server/src/stdio.rs +++ b/crates/gen_lsp_server/src/stdio.rs @@ -13,9 +13,7 @@ pub fn stdio_transport() -> (Receiver, Sender, Threads) let writer = thread::spawn(move || { let stdout = stdout(); let mut stdout = stdout.lock(); - writer_receiver - .into_iter() - .try_for_each(|it| it.write(&mut stdout))?; + writer_receiver.into_iter().try_for_each(|it| it.write(&mut stdout))?; Ok(()) }); let (reader_sender, reader_receiver) = bounded::(16); -- cgit v1.2.3