It's a small copy type so copying is more conventional.
warning: this argument is passed by reference, but would be more efficient if passed by value
--> src/protocol/frame/coding.rs:186:23
|
186 | pub fn is_allowed(&self) -> bool {
| ^^^^^ help: consider passing by value instead: `self`
|
= note: #[warn(trivially_copy_pass_by_ref)] on by default
= help: for further information visit https://rust-lang-nursery.github.io/rust-clippy/v0.0.212/index.html#trivially_copy_pass_by_ref
This is a breaking change.
warning: this argument is passed by value, but not consumed in the function body
--> src/protocol/message.rs:98:30
|
98 | pub fn new(message_type: IncompleteMessageType) -> Self {
| ^^^^^^^^^^^^^^^^^^^^^
|
= note: #[warn(needless_pass_by_value)] on by default
help: consider marking this type as Copy
--> src/protocol/message.rs:135:1
|
135| / pub enum IncompleteMessageType {
136| | Text,
137| | Binary,
138| | }
| |_^
= help: for further information visit https://rust-lang-nursery.github.io/rust-clippy/v0.0.212/index.html#needless_pass_by_value
warning: redundant closure found
--> src/protocol/mod.rs:114:43
|
114 | config: config.unwrap_or_else(|| WebSocketConfig::default()),
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove closure as shown: `WebSocketConfig::default`
|
= note: #[warn(redundant_closure)] on by default
= help: for further information visit https://rust-lang-nursery.github.io/rust-clippy/v0.0.212/index.html#redundant_closure
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
warning: this argument is passed by reference, but would be more efficient if passed by value
--> src/protocol/frame/mask.rs:21:46
|
21 | fn apply_mask_fallback(buf: &mut [u8], mask: &[u8; 4]) {
| ^^^^^^^^ help: consider passing by value instead: `[u8; 4]`
|
= help: for further information visit https://rust-lang-nursery.github.io/rust-clippy/v0.0.212/index.html#trivially_copy_pass_by_ref
warning: Constants have by default a `'static` lifetime
--> src/handshake/mod.rs:113:21
|
113 | const WS_GUID: &'static [u8] = b"258EAFA5-E914-47DA-95CA-C5AB0DC85B11";
| -^^^^^^^----- help: consider removing `'static`: `&[u8]`
|
= note: #[warn(const_static_lifetime)] on by default
= help: for further information visit https://rust-lang-nursery.github.io/rust-clippy/v0.0.212/index.html#const_static_lifetime
The reason for the unsafe was presumably to avoid copying or
zero-initializing. This achieves the same but using only safe functions.
Note: there is no zero-initializing here because Cursor is "trusted" to
not read from the buffer and so skips the initialization:
https://github.com/rust-lang/rust/blob/master/src/libstd/io/cursor.rs#L241
(the Take wrapper delegates to its inner).