Skip to content

Rename 'chain_one_line_max' to 'chain_width' #2115

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 5, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions Configurations.md
Original file line number Diff line number Diff line change
Expand Up @@ -227,26 +227,26 @@ let lorem = ipsum.dolor()
.elit();
```

See also [`chain_one_line_max`](#chain_one_line_max).
See also [`chain_width`](#chain_width).

## `chain_one_line_max`
## `chain_width`

Maximum length of a chain to fit on a single line

- **Default value**: `60`
- **Possible values**: any positive integer

#### Lines shorter than `chain_one_line_max`:
#### Lines shorter than `chain_width`:
```rust
let lorem = ipsum.dolor().sit().amet().consectetur().adipiscing().elit();
```

#### Lines longer than `chain_one_line_max`:
#### Lines longer than `chain_width`:
See [`chain_indent`](#chain_indent).

## `chain_split_single_child`

Split a chain with a single child if its length exceeds [`chain_one_line_max`](#chain_one_line_max).
Split a chain with a single child if its length exceeds [`chain_width`](#chain_width).

- **Default value**: `false`
- **Possible values**: `false`, `true`
Expand All @@ -264,7 +264,7 @@ let files = fs::read_dir("tests/coverage/source")
.expect("Couldn't read source dir");
```

See also [`chain_one_line_max`](#chain_one_line_max).
See also [`chain_width`](#chain_width).

## `closure_block_indent_threshold`

Expand Down
2 changes: 1 addition & 1 deletion src/chains.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ pub fn rewrite_chain(expr: &ast::Expr, context: &RewriteContext, shape: Shape) -
let one_line_budget = if rewrites.is_empty() && !context.config.chain_split_single_child() {
shape.width
} else {
min(shape.width, context.config.chain_one_line_max())
min(shape.width, context.config.chain_width())
};
let all_in_one_line = !parent_rewrite_contains_newline
&& rewrites.iter().all(|s| !s.contains('\n'))
Expand Down
4 changes: 2 additions & 2 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -587,9 +587,9 @@ create_config! {
report_fixme: ReportTactic, ReportTactic::Never, false,
"Report all, none or unnumbered occurrences of FIXME in source file comments";
chain_indent: IndentStyle, IndentStyle::Block, false, "Indentation of chain";
chain_one_line_max: usize, 60, false, "Maximum length of a chain to fit on a single line";
chain_width: usize, 60, false, "Maximum length of a chain to fit on a single line";
chain_split_single_child: bool, false, false, "Split a chain with a single child if its length \
exceeds `chain_one_line_max`";
exceeds `chain_width`";
imports_indent: IndentStyle, IndentStyle::Visual, false, "Indent of imports";
imports_layout: ListTactic, ListTactic::Mixed, false, "Item layout inside a import block";
reorder_extern_crates: bool, true, false, "Reorder extern crate statements alphabetically";
Expand Down
2 changes: 1 addition & 1 deletion tests/source/chains.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// rustfmt-normalize_comments: true
// rustfmt-single_line_if_else_max_width: 0
// rustfmt-chain_one_line_max: 100
// rustfmt-chain_width: 100
// Test chain formatting.

fn main() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// rustfmt-chain_one_line_max: 10
// rustfmt-chain_width: 10
// Chain one line max

fn main() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// rustfmt-chain_one_line_max: 100
// rustfmt-chain_width: 100
// Chain one line max

fn main() {
Expand Down
2 changes: 1 addition & 1 deletion tests/target/chains.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// rustfmt-normalize_comments: true
// rustfmt-single_line_if_else_max_width: 0
// rustfmt-chain_one_line_max: 100
// rustfmt-chain_width: 100
// Test chain formatting.

fn main() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// rustfmt-chain_one_line_max: 10
// rustfmt-chain_width: 10
// Chain one line max

fn main() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// rustfmt-chain_one_line_max: 100
// rustfmt-chain_width: 100
// Chain one line max

fn main() {
Expand Down