我可以仅将板条件属性应用于板条箱本身吗?
我有一个生锈项目,需要一些带有滴定的二进制文件。因此,我创建了源文件,例如src/bin/myfoobinary.rs
和src/bin/mybarbinary.rs
。编译器警告说,这些二元板条箱应该具有蛇案的名称,我想抑制该警告。
我可以将#![lose(non_snake_case)]
添加到板条箱中,但这也适用于板条箱的整个内容。不理想。我真的只想压制板条箱名称的警告。有可能吗?
I have a Rust project that needs a few binaries with TitleCaseNames. So I created source files like src/bin/MyFooBinary.rs
and src/bin/MyBarBinary.rs
. The compiler warns that these binary crates should have snake case names, and I want to suppress that warning.
I can add #![allow(non_snake_case)]
to the crate, but that then applies to the crate's entire contents as well. Not ideal. I really only want to suppress the warning for the crate name. Is that possible?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我建议按照源文件和板条箱名称的常规
snake_name
约定。由于您需要在部署或包装期间将二进制文件移动到其他地方,因此您可以在此时重命名。在夜间编译器构建中,您还可以指定与
cargo.toml
中的板条名称不同的文件名:I'd suggest to follow the usual
snake_name
convention for the source file and crate names. Since you need to move the binaries elsewhere during deployment or packaging anyway, you can rename them at that point.In the nightly compiler build, you can also specify a filename that is different from the crate name in
Cargo.toml
: