首页 > 解决方案 > 有没有办法防止格式化 else { 琐碎的表达式 }

问题描述

我经常有类似的代码

    if condition {
             // code that deserves to 
             // be formatted as block
    }
    else { None }   // or some other trivial expression

现在,有没有办法防止 rustfmt 浪费两行格式化琐碎的 else 部分,如下所示:

    else {
        None
    }

请注意,single_line_if_else_maxwidth这没有帮助,因为“then”部分太长了。

标签: rustrustfmt

解决方案


推荐阅读