首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何配置rustfmt来发出制表符而不是这些缩进空间?

如何配置rustfmt来发出制表符而不是这些缩进空间?
EN

Stack Overflow用户
提问于 2017-05-28 07:11:31
回答 1查看 3.2K关注 0票数 2

为什么rustfmt在下面的代码示例中发出缩进空格,以及如何将其配置为停止?

我有以下代码:

代码语言:javascript
复制
fn main() {
    if {
        let to_comp = true;
        if to_comp { true } else { false }
    } {
        println!("true");
    }
}

哪种rustfmt格式(我用--->替换了所有制表符,用``_替换了缩进空格,以说明缩进):

代码语言:javascript
复制
fn main() {
--->if {
--->--->___let to_comp = true;
--->--->___if to_comp { true } else { false }
--->--->__} {
--->--->println!("true");
--->}
}

以上代码的rustfmt.toml

代码语言:javascript
复制
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配置选项。因此,代码的格式如下:

代码语言:javascript
复制
fn main() {
--->if {
--->--->let to_comp = true;
--->--->if to_comp { true } else { false }
--->--->} {
--->--->println!("true");
--->}
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-05-29 03:57:19

你可以试试control_style = "Rfc"。输出如下:

代码语言:javascript
复制
fn main() {
    if {
        let to_comp = true;
        if to_comp { true } else { false }
    }
    {
        println!("true");
    }
}
票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/44224729

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档