Skip to content

Commit 8461e8a

Browse files
committed
Merge pull request #147 from marcusklaas/even-more-expr
Format if expressions & loops
2 parents 4aa24f5 + c4101de commit 8461e8a

25 files changed

+580
-45
lines changed

src/comment.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,11 @@ pub fn rewrite_comment(orig: &str, block_style: bool, width: usize, offset: usiz
1717
let s = orig.trim();
1818

1919
// Edge case: block comments. Let's not trim their lines (for now).
20-
let opener = if block_style { "/* " } else { "// " };
21-
let closer = if block_style { " */" } else { "" };
22-
let line_start = if block_style { " * " } else { "// " };
20+
let (opener, closer, line_start) = if block_style {
21+
("/* ", " */", " * ")
22+
} else {
23+
("// ", "", "// ")
24+
};
2325

2426
let max_chars = width.checked_sub(closer.len()).unwrap_or(1)
2527
.checked_sub(opener.len()).unwrap_or(1);

src/config.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,18 @@ use {NewlineStyle, BraceStyle, ReturnIndent, StructLitStyle};
1414
use lists::SeparatorTactic;
1515
use issues::ReportTactic;
1616

17+
#[derive(Copy, Clone, Eq, PartialEq, Debug)]
18+
pub enum BlockIndentStyle {
19+
// Same level as parent.
20+
Inherit,
21+
// One level deeper than parent.
22+
Tabbed,
23+
// Aligned with block open.
24+
Visual,
25+
}
26+
27+
impl_enum_decodable!(BlockIndentStyle, Inherit, Tabbed, Visual);
28+
1729
#[derive(RustcDecodable, Clone)]
1830
pub struct Config {
1931
pub max_width: usize,
@@ -31,6 +43,7 @@ pub struct Config {
3143
pub report_todo: ReportTactic,
3244
pub report_fixme: ReportTactic,
3345
pub reorder_imports: bool, // Alphabetically, case sensitive.
46+
pub expr_indent_style: BlockIndentStyle,
3447
}
3548

3649
impl Config {

src/default.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@ enum_trailing_comma = true
1313
report_todo = "Always"
1414
report_fixme = "Never"
1515
reorder_imports = false
16+
expr_indent_style = "Tabbed"

0 commit comments

Comments
 (0)