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
pull/39/head
Ran Benita 7 years ago
parent 556db990b5
commit c7a71106ac
  1. 2
      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);
}

Loading…
Cancel
Save