From 1329dd4e287c137ec0a90abeec0272275b2b2c8d Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sun, 2 Sep 2018 15:18:43 +0300 Subject: Avoid clones --- crates/gen_lsp_server/src/lib.rs | 4 ++-- crates/gen_lsp_server/src/msg.rs | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) (limited to 'crates/gen_lsp_server/src') diff --git a/crates/gen_lsp_server/src/lib.rs b/crates/gen_lsp_server/src/lib.rs index 0dc24ffc1..b25017045 100644 --- a/crates/gen_lsp_server/src/lib.rs +++ b/crates/gen_lsp_server/src/lib.rs @@ -51,7 +51,7 @@ pub fn run_server( pub fn handle_shutdown(req: RawRequest, sender: &Sender) -> Option { match req.cast::() { Ok((id, ())) => { - let resp = RawResponse::ok::(id, ()); + let resp = RawResponse::ok::(id, &()); sender.send(RawMessage::Response(resp)); None } @@ -72,7 +72,7 @@ fn initialize( msg => bail!("expected initialize request, got {:?}", msg), }; - let resp = RawResponse::ok::(id, InitializeResult { capabilities: caps }); + let resp = RawResponse::ok::(id, &InitializeResult { capabilities: caps }); sender.send(RawMessage::Response(resp)); match receiver.recv() { Some(RawMessage::Notification(n)) => { diff --git a/crates/gen_lsp_server/src/msg.rs b/crates/gen_lsp_server/src/msg.rs index 42241194d..7fcac6f6d 100644 --- a/crates/gen_lsp_server/src/msg.rs +++ b/crates/gen_lsp_server/src/msg.rs @@ -88,7 +88,7 @@ impl RawMessage { } impl RawRequest { - pub fn new(id: u64, params: R::Params) -> RawRequest + pub fn new(id: u64, params: &R::Params) -> RawRequest where R: Request, R::Params: Serialize, @@ -96,7 +96,7 @@ impl RawRequest { RawRequest { id: id, method: R::METHOD.to_string(), - params: to_value(¶ms).unwrap(), + params: to_value(params).unwrap(), } } pub fn cast(self) -> ::std::result::Result<(u64, R::Params), RawRequest> @@ -114,7 +114,7 @@ impl RawRequest { } impl RawResponse { - pub fn ok(id: u64, result: R::Result) -> RawResponse + pub fn ok(id: u64, result: &R::Result) -> RawResponse where R: Request, R::Result: Serialize, { @@ -135,14 +135,14 @@ impl RawResponse { } impl RawNotification { - pub fn new(params: N::Params) -> RawNotification + pub fn new(params: &N::Params) -> RawNotification where N: Notification, N::Params: Serialize, { RawNotification { method: N::METHOD.to_string(), - params: to_value(¶ms).unwrap(), + params: to_value(params).unwrap(), } } pub fn cast(self) -> ::std::result::Result -- cgit v1.2.3