How to remove Rust clippy warning `consider using the `vec![]` macro: `let mut https: Vec<u8> = vec![..];`

610 Views Asked by At

I have below rust code.

let mut https: Vec<u8>= Vec::new();
https.push(b'/');

When I am running cargo clippy, I am getting below warning

warning: calls to `push` immediately after creation
  https.push(b'/');
                  ^ help: consider using the `vec![]` macro: `let mut https: Vec<u8> = vec![..];`

Can somebody please help me to remove this warning?

1

There are 1 best solutions below

0
On

Clippy is advising that instead of pushing the new value manually you use the vec![] macro to construct a vector with the given items:

let https: Vec<u8> = vec![b'/'];