- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
为什么 rustfmt 在下面的代码示例中发出缩进空格,如何将其配置为停止?
我有以下代码:
fn main() {
if {
let to_comp = true;
if to_comp { true } else { false }
} {
println!("true");
}
}
which rustfmt formats as (我用 --->
替换了所有制表符,用 _
替换了缩进空格以说明缩进 ):
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");
--->}
}
最佳答案
您可以尝试 control_style = "Rfc"
。输出将如下所示:
fn main() {
if {
let to_comp = true;
if to_comp { true } else { false }
}
{
println!("true");
}
}
关于rust - 如何将 rustfmt 配置为发出制表符而不是这些缩进空格?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44224729/
某些 IDE 可以帮助实现类型可视化。以下是 VS Code 中的示例(《The Rust 编程语言》书中的示例略有修改): 但其他查看者(例如,用于公关评论的查看者)则不然。 是否可以以始终使类型显
某些 IDE 可以帮助实现类型可视化。以下是 VS Code 中的示例(《The Rust 编程语言》书中的示例略有修改): 但其他查看者(例如,用于公关评论的查看者)则不然。 是否可以以始终使类型显
因此,我正在为一个库生成绑定(bind),最重要的是,我正在为该库生成大部分安全包装器。 我的做法是简单地生成一个包含所有内容的字符串,然后使用 File 特征写入文件... 我知道绑定(bind)箱
让 Rustfmt 跳过一个项目的官方方法是 #[rustfmt::skip] ,但是我希望它跳过整个文件。我试过这个: #![rustfmt::skip] 但是你得到这个错误 error[E0658
我有大量使用 rustfmt 的默认缩进设置格式不佳的结构。对于这个特定的声明,Visual 缩进更合适。 是否可以使用属性配置每个声明的格式,以便我可以根据需要提供缩进设置(或任何设置)? 最佳答案
为什么 rustfmt 在下面的代码示例中发出缩进空格,如何将其配置为停止? 我有以下代码: fn main() { if { let to_comp = true;
我想使用宏来生成相同的 impl多种混凝土类型的块。我的代码目前看起来像这样: macro_rules! impl_methods { ($ty:ty, { $($method:item);
我的 rustfmt 配置当前将以下代码格式化为具有对齐空格,如下所示。在以下代码中,我用 . 替换了空格,用 ---> 替换了制表符。 fn main() { --->match unsafe {
我使用 Rust nightly 2015/07/18 在 x64 Windows 8.1 PC 上构建了 rustfmt 的最新主分支。 cargo build --release rustfmt
我使用的是 macOS Mojave。我过去使用过 Rust,并且 rustfmt 一直有效,但我无法再下载 rustfmt。 $ rustup show Default host: x86_64-a
我如何运行 rustfmt当我在 IntelliJ 或 CLion 中保存文件时自动? 最佳答案 应该注意的是,虽然 bit2pixel 的答案会起作用(确实是我做了很长时间的方法),但还有一种更新(
我运行了 rustup update 来更新我的工具链并看到了两个警告: warning: tool `rustfmt` is already installed, remove it from `/
我是一名优秀的程序员,十分优秀!