我想用单个多行字符串参数调用宏,像这样的格式:
css!(r"
background: grey;
color: white;
");
但是,rustfmt坚持将字符串字面的字样贴在自己的行上,这
css!(
r"
background: grey;
color: white;
"
);
很丑即使有多行?
我知道Rustfmt可以是配置,,,,但是我找不到这个选择,我真的不知道要搜索什么。
I would like to call macros with a single multi-line string argument, formatted like so:
css!(r"
background: grey;
color: white;
");
However, Rustfmt insists on putting the string literal on its own line, which is ugly and takes up more space:
css!(
r"
background: grey;
color: white;
"
);
Is there a way I can tell Rustfmt to not put a single string literal on its own line, even when it has multiple lines?
I am aware that Rustfmt can be configured, but I couldn't find an option for this and I don't really know what to search for.
发布评论
评论(1)
您可以使用
#[Rustfmt :: Skip]
告诉Rustfmt不要格式化代码:Rustfmt还跳过支撑宏,因此您也可以这样做:
您也可以使用
##[Rustfmt :: Skip:skip:skip:skip: :macros(...)]
始终跳过此宏:全部应用(请参阅使用内部属性,但这是不稳定的:
You can use
#[rustfmt::skip]
to tell rustfmt to not format code:rustfmt also skips braced macros, so you can do:
You can also use
#[rustfmt::skip::macros(...)]
to always skip this macro:To apply it whole-file (see Is there a stable way to tell Rustfmt to skip an entire file), you can either apply it to the module declaration, or use an inner attribute, but that's unstable: