[英]How to remove Rust clippy warning `consider using the `vec![]` macro: `let mut https: Vec<u8> = vec![..];`
I have below rust code.我有以下 rust 代码。
let mut https: Vec<u8>= Vec::new();
https.push(b'/');
When I am running cargo clippy
, I am getting below warning当我运行cargo clippy
时,我得到以下警告
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?有人可以帮我删除这个警告吗?
Clippy is advising that instead of pushing the new value manually you use the vec![]
macro to construct a vector with the given items: Clippy 建议不要手动推送新值,而是使用vec![]
宏来构造具有给定项目的向量:
let https: Vec<u8> = vec![b'/'];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.