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.
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: