From c7a71106acab415aebfbef85765ba156d1440ae8 Mon Sep 17 00:00:00 2001 From: Ran Benita Date: Tue, 10 Jul 2018 23:37:59 +0300 Subject: [PATCH] handshake: switch unwrap_or to a lazy unwrap_or_else warning: use of `unwrap_or` followed by a function call --> src/handshake/client.rs:55:53 | 55 | let mut headers = self.extra_headers.take().unwrap_or(vec![]); | ^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| < [ _ ] > :: into_vec ( box [ $ ( $ x ) , * ] ))` | = note: #[warn(or_fun_call)] on by default = help: for further information visit https://rust-lang-nursery.github.io/rust-clippy/v0.0.212/index.html#or_fun_call --- src/handshake/client.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/handshake/client.rs b/src/handshake/client.rs index 82a297a..615b413 100644 --- a/src/handshake/client.rs +++ b/src/handshake/client.rs @@ -52,7 +52,7 @@ impl<'t> Request<'t> { /// Adds a custom header to the request. pub fn add_header(&mut self, name: Cow<'t, str>, value: Cow<'t, str>) { - let mut headers = self.extra_headers.take().unwrap_or(vec![]); + let mut headers = self.extra_headers.take().unwrap_or_else(|| vec![]); headers.push((name, value)); self.extra_headers = Some(headers); }