为什么rustfmt会在下面的代码示例中发出缩进空格,以及如何将其配置为停止?
我有以下代码:
fn main() {
if {
let to_comp = true;
if to_comp { true } else { false }
} {
println!("true");
}
}
哪个rustfmt格式为(我已用--->
替换所有标签,而缩进空格用_
来说明缩进):
fn main() {
--->if {
--->--->___let to_comp = true;
--->--->___if to_comp { true } else { false }
--->--->__} {
--->--->println!("true");
--->}
}
我的rustfmt.toml
以上代码:
tab_spaces = 4
hard_tabs = true
array_layout = "Block"
reorder_imports = true
newline_style = "Unix"
spaces_within_angle_brackets = false
spaces_within_parens = false
spaces_within_square_brackets = false
fn_args_layout = "Block"
fn_call_style = "Block"
fn_return_indent = "WithArgs"
fn_brace_style = "SameLineWhere"
generics_indent= "Block"
item_brace_style = "PreferSameLine"
where_layout = "Horizontal"
where_pred_indent = "Block"
where_style = "Rfc"
我想知道是否存在rustfmt
配置选项,它只会发出缩进选项卡。所以代码的格式如下:
fn main() {
--->if {
--->--->let to_comp = true;
--->--->if to_comp { true } else { false }
--->--->} {
--->--->println!("true");
--->}
}
答案 0 :(得分:3)
您可以尝试control_style = "Rfc"
。输出将如下所示:
fn main() {
if {
let to_comp = true;
if to_comp { true } else { false }
}
{
println!("true");
}
}