在使用clippy的Rust中,我如何禁用clippy::struct过多的bools



当我运行"货物剪贴簿-W剪贴簿:"迂腐的";在下面的代码上,我得到了消息:

note: `-W clippy::struct-excessive-bools` implied by `-W clippy::pedantic`
help: consider using a state machine or refactoring bools into two-variant enums
help: for further information visit https://rust-lang.github.io/rust clippy/master/index.html#struct_excessive_bool

我曾尝试用#[allow(clippy::clippy:::struct excessed bools(]禁用此功能,但失败了:

5 | #[allow(clippy::clippy::struct-excessive-bools)]
|                         ^^^^^^ expected identifier, found keyword

使用#[allow(clippy::clippy::pedantic(]是唯一的解决方案吗?

''

use clap::Parser;
#[derive(Parser, Default, Debug)]
#[clap(version, about)]
#[allow(clippy::clippy::struct-excessive-bools)]
struct Arguments {
#[clap(short, long)]
/// Set aaa
aaa: bool,
#[clap(short, long)]
/// Set bbb
bbb: bool,
#[clap(short, long)]
/// Set ccc
ccc: bool,
#[clap(short, long)]
/// Set ddd
ddd: bool,
}
fn main() {
let args = Arguments::parse();
dbg!(args);
}

''

lint命名为clippy::struct_excessive_bools,使用下划线而不是连字符;而且它不需要额外的名称空间。CCD_ 2工作-运行CCD_;工具;按钮位于右上角,带有或不带有要查看的属性。

最新更新