Skip to content

Commit

Permalink
build: Fix clippy errors
Browse files Browse the repository at this point in the history
This patch is for fixing the following errors:

   --> src/lib.rs:359:9
    |
358 |           let mut server_version_data = Vec::new();
    |                                         ---------- help: consider replacing this with: `vec![0; server_version.header.message_size as usize - size_of::<Version>()]`
359 | /         server_version_data.resize(
360 | |             server_version.header.message_size as usize - size_of::<Version>(),
361 | |             0,
362 | |         );
    | |_________^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#slow_vector_initialization
    = note: `-D clippy::slow-vector-initialization` implied by `-D warnings`
    = help: to override `-D warnings` add `#[allow(clippy::slow_vector_initialization)]`

Signed-off-by: Bo Chen <chen.bo@intel.com>
  • Loading branch information
likebreath committed Jan 17, 2024
1 parent e0bdd2f commit 348b491
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -355,11 +355,8 @@ impl Client {

debug!("Reply: {:?}", server_version);

let mut server_version_data = Vec::new();
server_version_data.resize(
server_version.header.message_size as usize - size_of::<Version>(),
0,
);
let mut server_version_data =
vec![0; server_version.header.message_size as usize - size_of::<Version>()];
self.stream
.read_exact(server_version_data.as_mut_slice())
.map_err(Error::StreamRead)?;
Expand Down Expand Up @@ -897,8 +894,8 @@ impl Server {
.read_exact(&mut client_version.as_mut_slice()[size_of::<Header>()..])
.map_err(Error::StreamRead)?;

let mut raw_version_data = Vec::new();
raw_version_data.resize(header.message_size as usize - size_of::<Version>(), 0u8);
let mut raw_version_data =
vec![0; header.message_size as usize - size_of::<Version>()];
stream
.read_exact(&mut raw_version_data)
.map_err(Error::StreamRead)?;
Expand Down

0 comments on commit 348b491

Please sign in to comment.