首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何配置rustfmt不为匹配不安全的块模式发出对齐空间?

如何配置rustfmt不为匹配不安全的块模式发出对齐空间?
EN

Stack Overflow用户
提问于 2017-06-05 07:53:20
回答 1查看 419关注 0票数 0

我的rustfmt配置当前将下面的代码格式化为对齐空格,如下所示。在下面的代码中,我用.替换了空格,用--->替换了制表符。

代码语言:javascript
复制
fn main() {
--->match unsafe {
--->--->......0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1
--->--->.....} {
--->--->0 => println!("0"),
--->--->_ => println!("not 0 or 1"),
--->}
}

生成上述代码示例的rustfmt配置(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"
control_style = "Rfc"
match_style = "Rfc"
unsafe_style = "Rfc"
where_layout = "Horizontal"
where_pred_indent = "Block"
where_style = "Rfc"

如何将rustfmt配置为不为前面的代码发出对齐空格(标记为:.),因此rustfmt只具有标签缩进,如下面的代码所示?

代码语言:javascript
复制
fn main() {
--->match unsafe {
--->--->0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1
--->--->} {
--->--->0 => println!("0"),
--->--->_ => println!("not 0 or 1"),
--->}
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-06-05 09:05:58

这是个窃听器。我创建了一个按下来修复这个问题,所以当它被合并后,rustfmt就不会发出带有您的配置的空间。

票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/44364221

复制
相关文章

相似问题

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