我想用一个多行字符串参数调用宏,格式如下:
css!(r"
background: grey;
color: white;
");然而,Rustfmt坚持将字符串文字放在自己的行上,这很难看,占用了更多的空间:
css!(
r"
background: grey;
color: white;
"
);有没有办法告诉Rustfmt不要在自己的行上放置一个字符串文字,即使它有多行?
我知道Rustfmt可以是配置,但是我找不到这个选项,我也不知道该搜索什么。
发布于 2022-05-05 22:52:11
您可以使用#[rustfmt::skip]告诉rustfmt不要格式化代码:
#[rustfmt::skip]
css!(r"
background: grey;
color: white;
");rustfmt也跳过带括号的宏,因此您可以:
css! { r"
background: grey;
color: white;
" };您还可以使用#[rustfmt::skip::macros(...)]始终跳过这个宏:
#[rustfmt::skip::macros(css)]
fn foo() { ... }要应用整个文件(请参阅有没有稳定的方法告诉Rustfmt跳过整个文件),可以将其应用于模块声明,也可以使用内部属性,但这是不稳定的:
#![feature(custom_inner_attributes)]
#![rustfmt::skip::macros(css)]https://stackoverflow.com/questions/72124652
复制相似问题