rust - 有没有办法防止格式化 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”部分太长了。
解决方案
推荐阅读
- android - RecyclerView with CardView Items, notifyItemChanged 和 shadow 问题
- r - 在 R 中有什么方法可以在一列中找到“文本”,将相同的值放在 R 数据框中的另一列中?
- excel - 如何将日期中的月份替换为特定月份?
- matlab - 为什么通过 lsqcurvefit 和 fminunc 函数获得的标准误差不同?
- python - Pandas DataFrame Groupby 两列并添加移动平均列
- ms-access - 如何在 MS Access 中添加验证或输入掩码?
- javascript - Fullcalendar v4:上一个按钮和浏览器后退按钮集成失败
- javascript - 无法将带有 "" 、 '' 和 /n 的字符串从 PHP 回显到 JavaScript
- excel - 是否可以将两个具有不同行和列的 Excel 电子表格组合在一起?
- macos - 在 OSX 中获取鼠标按钮状态