基本的方法就是代码添加#[allow(dead_code)] 或 #![allow(dead_code)]。 #[allow(dead_code)]: 随时需要随时添加,添加到告警行代码的上方,只生效当前代码。若编写lib的时候,有些代码是为了导出给他人调用,可使用该方法 #![allow(dead_code, unused_imports)]: 一次添加,整体有效。添加到lib.rs或者main.rs...
如果要允许未使用的代码,在前面加上 #[allow(dead_code)] 即可。 参考文献: https://doc.rust-lang.org/rust-by-example/attribute/unused.html
#[allow(dead_code)] enumColor{ Red, Blue, Green, RGB(u32,u32,u32), HSV(u32,u32,u32), HSL(u32,u32,u32) } fnmain() { letcolor=Color::RGB(122,17,40); println!("what color is it ?"); matchcolor{ Color::Red=>println!("The color is Red!"), Color::RGB(a,b,c)=>...
由于目前我们暂时只用到了send_text方法,因此编译期会发出send_binary未使用的警告,我们使用#[allow(dead_code)]进行标记即可。 管理客户端连接 ws/src/manager.rs use std::sync::Arc; use abi::message::Msg; use dashmap::DashMap; use tokio::sync::mpsc::{self, error::SendError}; use tracing...
rust note: `#[warn(dead_code)]` on by default,如果要允许未使用的代码,在前面加上#[allow(dead_code)]即可。参考文献:https://doc.rust-lang.org/rust-by-example/attribute/unused.html
When this setting is true, dead_code would analyze an entire workspace, checking that all code is used somewhere in the workspace. This is particularly useful in projects that have libraries (for compilation speed or modularity reasons) that are never intended to be published. In those cases, ...
[allow(dead_code)]#![allow(unused_variables)]usestd::{sync::Mutex};useconfig::Config;usetoml::{Value};lazy_static::lazy_static!{pubstaticrefCONFIG:Mutex<Value>=Mutex::new(load_config());}pubfnload_config()->toml::Value{letsettings=Config::builder()// Add in `./Settings.toml`.add...
#[allow(dead_code)] fn unused_function() {} 这眼睛真是辣了,怎么还来个脚本语言的注释?细细一看,哦,这叫Attribute,能干很多事,如: 条件编译代码 设置crate 名称、版本和类型(二进制文件或库) 禁用lint (警告) 启用编译器的特性(宏、全局导入(glob import)等) ...
{fncall_box(self:Box<F>){(*self)()}}pubtypeTask=Box<dynFnBox+Send>;pubstructWorkerPool{tx:Rc<RefCell<Option<Sender<Task>>>,#[allow(dead_code)]handlers:Option<Vec<thread::JoinHandle<()>>>,}implWorkerPool{pubfnnew(number:usize)->WorkerPool{let(tx,rx)=channel::<Task>();letmuthandl...
[allow(unused_variables)] // <1>type File=String;// <2>fnopen(f:&mut File)->bool{true// <3>}fnclose(f:&mut File)->bool{true// <3>}#[allow(dead_code)]// <4>fnread(f:&mut File,save_to:&mut Vec<u8>)->!{// <5>unimplemented!()// <6>}fnmain(){letmut f1=File::...